• ☆ Yσɠƚԋσʂ ☆@lemmygrad.mlOP
    link
    fedilink
    arrow-up
    18
    arrow-down
    1
    ·
    10 days ago

    If most of the code you write is meaningful code that’s novel and interesting then you are incredibly privileged. Majority of code I’ve seen in the industry is mostly boring and a lot of it just boilerplate.

    • footfaults@lemmygrad.ml
      link
      fedilink
      English
      arrow-up
      10
      ·
      10 days ago

      meaningful code that’s novel and interesting then you are incredibly privileged

      This is possible but I doubt it. It’s your usual CRUD web application with some business logic and some async workers.

        • footfaults@lemmygrad.ml
          link
          fedilink
          English
          arrow-up
          7
          ·
          10 days ago

          Not really. It’s Django and Django Rest Framework so there really isn’t a lot of boilerplate. That’s all hidden behind the framework

          • ☆ Yσɠƚԋσʂ ☆@lemmygrad.mlOP
            link
            fedilink
            arrow-up
            5
            ·
            10 days ago

            I’d argue that most of the code is conceptually boilerplate, even when you have a framework to paper over it. There’s really nothing exciting about declaring an HTTP endpoint that’s going to slurp some JSON, massage it a bit, and shove it n your db. It’s a boring repetitive task, and I’m happy to let a tool do it for me.

            • footfaults@lemmygrad.ml
              link
              fedilink
              English
              arrow-up
              2
              ·
              edit-2
              10 days ago

              What I’m trying to say is that for Django, especially Django Rest Framework, you don’t even declare endpoints.

              DRF has a ModelViewSet where you just create a class, inherit from MVS and set the model to point to your Django ORM model and that’s it. ModelViewSet already has all the implementation code for handling POST, PUT, PATCH and DELETE.

              There is no boilerplate.

              There isn’t anything that an LLM would add to this process.

                • footfaults@lemmygrad.ml
                  link
                  fedilink
                  English
                  arrow-up
                  2
                  ·
                  10 days ago

                  Around which parts of Django? Because Django has generic class based views that do exactly the same thing, where all you do is set the model attribute. Then the generic view class you inherited from has the implementation. Especially if you use a ModelForm

                  • ☆ Yσɠƚԋσʂ ☆@lemmygrad.mlOP
                    link
                    fedilink
                    arrow-up
                    6
                    ·
                    10 days ago

                    Here’s what a typical Django enpoint might look like for handling a json payload with some user information and storing it in the db:

                    from django.db import models
                    
                    class UserProfile(models.Model):
                        username = models.CharField(max_length=100, unique=True, help_text="Unique username")
                        email = models.EmailField(unique=True, help_text="User's email address")
                        full_name = models.CharField(max_length=255, blank=True, null=True, help_text="User's full name")
                        date_joined = models.DateTimeField(auto_now_add=True, help_text="Date when the user profile was created")
                        is_active = models.BooleanField(default=True, help_text="Designates whether this user should be treated as active.")
                    
                        def __str__(self):
                            return self.username
                    
                        class Meta:
                            ordering = ['-date_joined']
                            verbose_name = "User Profile"
                            verbose_name_plural = "User Profiles"
                    

                    then you’ll probably need to add some serializers

                    from rest_framework import serializers
                    from .models import UserProfile
                    
                    class UserProfileSerializer(serializers.ModelSerializer):
                        class Meta:
                            model = UserProfile
                            fields = ['id', 'username', 'email', 'full_name', 'date_joined', 'is_active']
                            read_only_fields = ['id', 'date_joined']
                    
                        def validate_username(self, value):
                            if not value:
                                raise serializers.ValidationError("Username cannot be empty.")
                            if len(value) < 3:
                                raise serializers.ValidationError("Username must be at least 3 characters long.")
                            # Add any other custom username validation rules here
                            return value
                    
                        def validate_email(self, value):
                            if not value:
                                raise serializers.ValidationError("Email cannot be empty.")
                            # Django's EmailField already provides good validation,
                            # but you can add more specific rules if needed.
                            return value
                    

                    then you’ll have to add some views

                    from rest_framework.decorators import api_view
                    from rest_framework.response import Response
                    from rest_framework import status
                    from .models import UserProfile
                    from .serializers import UserProfileSerializer
                    
                    @api_view(['POST'])
                    def create_user_profile(request):
                        if request.method == 'POST':
                            serializer = UserProfileSerializer(data=request.data)
                    
                            if serializer.is_valid():
                                serializer.save()
                                return Response(serializer.data, status=status.HTTP_201_CREATED)
                            else:
                                return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
                        return Response({"error": "Method not allowed"}, status=status.HTTP_405_METHOD_NOT_ALLOWED)
                    

                    next you have to define URL patterns

                    from django.urls import path
                    from .views import create_user_profile
                    
                    urlpatterns = [
                        path('users/create/', create_user_profile, name='create-user-profile'),
                    ]
                    

                    This is all just a bunch of boilerplate. And with LLMs, you can just give it a sample JSON payload you want and this stuff just happens.

    • 小莱卡@lemmygrad.ml
      link
      fedilink
      English
      arrow-up
      7
      ·
      edit-2
      10 days ago

      Absolutely, coders should be spending time developing new and faster algorithms, things that AI cannot do, not figuring out the boilerplate of a dropbox menu on whatever framework. Heck, we dont even need frameworks with AI.