• NigelFrobisher@aussie.zone
    link
    fedilink
    arrow-up
    1
    ·
    2 分钟前

    Developers who think they’re following the patterns, but they never even read the books and they’re still just doing whatever but naming it like it’s the pattern.

  • ZILtoid1991@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    2 小时前

    The self documenting code: short acronyms, that will make you go “AHA!” after hours of rubber ducking.

      • theneverfox@pawb.social
        link
        fedilink
        English
        arrow-up
        8
        ·
        10 小时前

        Nope, sorry. I just break my code into neatly grouped chunks, and I’m very consistent

        I regularly go “I need something to do X”, and when I go to write it it’s already there. It does exactly what I need it to do, otherwise why would I name it X and not X_for_situation_y? I would never

        My utility functions are reusable, my classes handle their own logic internally, and so my business logic is clean and readable. My code flows straight and clear, along a single path whenever possible

        So yeah… When I start working with people, there’s the initial confusion then this moment where they go “Oh! That’s really easy to understand”

          • theneverfox@pawb.social
            link
            fedilink
            English
            arrow-up
            1
            ·
            2 小时前

            But honestly, it’s probably because I have ideasthesia. I feel ideas tactically

            Bad code feels slimy, problem areas feel like sharp angles, good code feels clean and smooth, like a smooth river stone with clean even grooves that gracefully curve

            Best advice I can give is to strive to write elegant code. I don’t strictly follow style guides or do docstrings… These are superficial. I try to match the style of the project, but my code is consistent even in projects that are not

            Elegant code is pretty, regardless of formatting. You’ll know it when you see it, junior devs will follow the patterns without instruction. It does not require explanation, it does exactly what you think it does, and it makes complex problems simple

          • theneverfox@pawb.social
            link
            fedilink
            English
            arrow-up
            2
            ·
            3 小时前

            Yes, but only ship of thesius style

            I’ve seen how people code, I’m writing my own stack on the way up

  • ttyybb@lemmy.world
    link
    fedilink
    arrow-up
    118
    arrow-down
    1
    ·
    2 天前

    A skilled programmer can make self documenting code, so I always document mine.

    • MotoAsh@piefed.social
      link
      fedilink
      English
      arrow-up
      20
      arrow-down
      2
      ·
      edit-2
      1 天前

      Nah. No code actually documents itself. Ever. Anyone who says they can is an idiot that doesn’t understand the purpose of comments and docs.

      Code can never describe intent, context, or consequences unless you read every line of code in every library and framework used, and every external call. Especially if they aren’t doing “fail fast” correctly.

        • MotoAsh@piefed.social
          link
          fedilink
          English
          arrow-up
          12
          ·
          edit-2
          1 天前

          I did not say comments should directly explain what the code is obviously attempting to do.

          • ChickenLadyLovesLife@lemmy.world
            link
            fedilink
            English
            arrow-up
            12
            ·
            edit-2
            1 天前

            My favorite thing about the “all comments are bad” crowd is that their first example is almost always something like this:

            // Add 1 to x
            x = x + 1
            

            Like, nobody that thinks comments are good and important would ever add a useless comment like that. The point of commenting is to add documentation (usually the only form of documentation that a future developer is ever going to read) only to code that would otherwise be inscrutable.

            • Hudell@lemmy.dbzer0.com
              link
              fedilink
              English
              arrow-up
              2
              ·
              edit-2
              21 小时前

              You’d think that, and yet I’ve once worked in a project in a fortune 500 company that basically wouldn’t even compile if we didn’t add comments like that. No kidding the compiler enforced specific comment patterns so if you had a line do x = x + 1, it would not compile if it was not preceded by a comment that started with “Add” and included “1” and “to x”. Even in dev mode if you wanted to just try something you had to comment everything.

              The original dev was super proud of this tools that generated HTML documentation about everything based on those comments. And the whole documentation was stuff like:

              *price*: The price
              
    • SeductiveTortoise@piefed.social
      link
      fedilink
      English
      arrow-up
      28
      ·
      2 天前

      I inherited a code base probably written by a squirrel, and the first thing I did was to write documentation on infrastructure, business logic, architecture, deployment and whatever. I had to read everything anyways, because the guy handing it over had no idea what it did and left the company shortly after. It’s fine now, but that path was horrible.

  • jubilationtcornpone@sh.itjust.works
    link
    fedilink
    arrow-up
    62
    arrow-down
    1
    ·
    2 天前
    /*
    By all accounts, the logic in this method shouldn't work. And yet it does. We do not know why. It makes no sense whatsoever. It took three weeks and numerous offerings to the programming gods, including using one of the junior devs as a human sacrifice, to unlock this knowledge. DO NOT LET HIS VIOLENT AND UNTIMELY DEATH BE IN VAIN! Touch this at your own peril.
    --jubilationtcornpone 12/17/25
    */
    public async Task<IResult> CalculateResultAsync()
    {
         // Some ass backwards yet miraculously functional logic.
    }
    
    • ChickenLadyLovesLife@lemmy.world
      link
      fedilink
      English
      arrow-up
      10
      ·
      1 天前

      That long-ass horizontal scroll bar reminds me of how I used to put unfindable easter eggs into my Visual Basic apps. I would have amusing little messages pop up from time to time in message boxes. To prevent anyone from just searching for the exact text in the message box, I would reduce it to a series of concatenated Chr() statements and then I would put like 200 characters of whitespace in front of the message box call. The only way anybody would spot it would be if they noticed the horizontal scroll bar this produced and nobody ever did.

      At least that’s my theory. It’s also possible that nobody ever used the software that I produced.

      • Hudell@lemmy.dbzer0.com
        link
        fedilink
        English
        arrow-up
        4
        ·
        22 小时前

        A friend of mine used to teach coding decades ago and one story I’ll never forget is about the student who had an assignment that asked for a “for” loop to be used, but they didn’t quite know how to use it so they just wrote a broken loop there and then hid a “while” loop at the far end of the line.

        Code compiled, had a “for” loop and had the right output.

  • RedFrank24@piefed.social
    link
    fedilink
    English
    arrow-up
    58
    arrow-down
    2
    ·
    2 天前

    The only times I’ve seen devs do inline comments in their code is when it’s been done by AI, and I can tell it’s AI because the comments are all useless and describing what’s happening, not why.

    • x00z@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      3 小时前

      I do it all the time because I prefer to read comments over code, long before LLMs were a thing.

    • Eiri@lemmy.ca
      link
      fedilink
      arrow-up
      55
      ·
      2 天前
      // Format user object
      function formatUserObject(user) {
      

      I’ve seen lots of such crap written by humans. I guess AI had to learn it from somewhere.

      • Thorry@feddit.org
        link
        fedilink
        arrow-up
        19
        ·
        2 天前

        AI mostly learned it from programming tutorials and things like documentation and Q&A forums like StackOverflow. People often add comments in those cases to explain to somebody not familiar with code what is happening so they can learn from it.

        In actual code written by people who write code for a living I’d hope the comments are much more useful and usually not as prevalent.

      • definitemaybe@lemmy.ca
        link
        fedilink
        arrow-up
        4
        arrow-down
        1
        ·
        1 天前

        I actually got really clean, well commented code from Copilot earlier this week.

        I have no experience with JavaScript to speak of, but realized a Bookmarklet would be a perfect solution for reformatting a particular arcuate for printing. I already had a head replacement with CSS to do all the formatting, and I was using a RegEx to strip all script tags.

        Anyway, I asked Copilot to write the Bookmarklet to replace the header, with full contents explaining the training behind the code, and an explanation of how the script functions below. When I got an error, I asked if to fix the error and or identified that Bookmarklets work better as single lines, so it fixed it. Then I added the requirement about replacing scripts, and it did that too, but for commented and a clean one-line version.

        The one-live versions even up getting truncated, so I need to copy/paste from earlier (correct) endings, but otherwise it was an incredibly smooth experience.

        I spent longer writing the guide for how to use it than the time it took to vibe code it and test it. I was super impressed.

        (Granted, that’s a pretty easy coding task…)

          • definitemaybe@lemmy.ca
            link
            fedilink
            arrow-up
            1
            ·
            3 小时前

            I’ve copied and pasted other people’s Bookmarklets before. ;)

            I’ve had a couple decades of eclectic, self-directed tech learning. There’s no money for technology in education, so I’m always kludging things together, and there’s nobody at any school I’ve ever worked at who can teach me much, so I need to figure shit out myself.

            It’d have been nice to be a junior to a greybeard for a few years, but I’ve made it work.

        • Clent@lemmy.dbzer0.com
          link
          fedilink
          English
          arrow-up
          6
          ·
          1 天前

          no experience with JavaScript to speak of

          You claim no JavaScript experience, declare confident in the comments and include any examples.

          All you’ve really said here is you vibed coded a solution to a problem using one of the most common languages without knowing the language. And made claims you do not attempt to prove.

          • definitemaybe@lemmy.ca
            link
            fedilink
            arrow-up
            1
            ·
            edit-2
            10 小时前

            I know enough to parse the code, especially with the comments. It was a logical algorithm, it worked, and it was just for reformatting a page to print cleanly, so there was basically no risk if it didn’t work. I code for work, I just don’t know JavaScript syntax or functions.

            Anyway, I was impressed it actually worked. I’m an AI skeptic, which is why I thought it was noteworthy to get well documented, clean, functional code from vibe coding—even in such a trivial context as swapping a head tag and removing script tags.

            • Clent@lemmy.dbzer0.com
              link
              fedilink
              English
              arrow-up
              1
              ·
              12 小时前

              a trivial context as swapping a head tag and removing script tags.

              Very curious what it actually generated here because that sounds really basic but as coders we tend to downplay complexity when describing things (why our documentation is often bad) so maybe it’s more than just some trivial dom manipulation.

      • Thorry@feddit.org
        link
        fedilink
        arrow-up
        24
        ·
        edit-2
        2 天前

        // 🤦 You are totally right! Simply logging the 🚨 error to the console isn't proper error handling. 🫣 We now throw an exception instead. throw new ApplicationException(error);

      • tauonite@lemmy.world
        link
        fedilink
        arrow-up
        5
        ·
        edit-2
        1 天前

        I once tried vibe coding a web app using GitHub Copilot. That motherfucker wrapped every single endpoint with

        try:
            ...
        except Exception:
            return "An error occurred"
        

        What the fuck is wrong with you Copilot? This piece of shit trying to hide all the errors. If I don’t know there are errors then there aren’t errors. Apparently

        • bitjunkie@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          12 小时前

          It’s actually kind of hilarious how closely it mimics a human programmer who just sucks at it.

        • ChickenLadyLovesLife@lemmy.world
          link
          fedilink
          English
          arrow-up
          3
          ·
          edit-2
          1 天前

          I wish to god Visual Basic was still around so Copilot et. al. could get infected with ON ERROR RESUME NEXT statements. Or its under-appreciated but vastly more horrific cousin ON ERROR RESUME.

          • pinball_wizard@lemmy.zip
            link
            fedilink
            arrow-up
            2
            ·
            edit-2
            22 小时前

            I might make that my first coding project after I retire. I bet I can code up a global import that implements “ON ERROR RESUME” in a couple of modern languages…

    • nogooduser@lemmy.world
      link
      fedilink
      English
      arrow-up
      15
      ·
      2 天前

      I sometimes suspect that I am actually an AI. I’ve always struggled with captchas and I comment my code exactly as you’ve just described.

      • vrek@programming.dev
        link
        fedilink
        English
        arrow-up
        7
        ·
        1 天前

        Proper comments describe why… For example say you are using an api which requires guids and your application doesn’t care are collisions as much so just use int id’s.

        You could add in a comment like

        // creating a guid to interface with special api.

        But just saying

        // generate guid

        Means nothing, your method should be generate_guid() or GenerateGuid(). Your comment is repeating.

        Or this is probably going to hit my last company at some point, there was a system to read a serial number. They also wanted a “status” on the screen to verify the system was connected and running properly but both these values came over same signal wire. Depending on your exact ms timing sometimes you would read the status as the serial number. Another programmer wrote a check to verify the serial number did not start with OK. The comment added was

        // add on 11/15/23 by Initials

        With no other details. The serial numbers were 8 numeric digits. Someone won’t know the history and delete this seemingly useless check and cause a 10s of 1000s of dollars in loss

        • anomnom@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          6
          ·
          edit-2
          1 天前

          I used to write it all the steps I thought I’d need as these types of comments, then go back and write the real methods. But I usually replaced the comments with more detailed jsdocs style comments with as much detail about the parameters as returnvalues as possible.

          Then I quit web dev and moved to the woods.