you are viewing a single comment's thread
view the rest of the comments
[–] 232 points 5 months ago (24 children)

god, this code is awful. Who wrote this?

git blame

Oh

  • source
  • hideshow 24 child comments
  • [–] 111 points 5 months ago (2 children)

    Been writing the same software for 20+ years now, don't even need git blame to figure out what asshole wrote this shit.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 28 points 5 months ago (1 child)

    That exact chain of events happened to me at my last job and I audibly laughed realising it was my own code. To my own credit though, it was a file I had written four years prior which at that point was more than half my whole career in the past

  • source
  • parent
  • hideshow 1 child comment
  • [–] 13 points 5 months ago

    These days I see so much AI slop that my reaction when I see code I hand-wrote myself is "hey, that's pretty good".

    My team's code is great, but we use a lot of shared code written by other teams, with varying levels of quality.

  • source
  • parent
  • [–] 9 points 5 months ago (3 children)

    I mean, admitting you have a problem is the first step to a solution…

  • source
  • parent
  • hideshow 3 child comments
  • [–] 5 points 5 months ago* (last edited 5 months ago) (7 children)

    I have lately jokingly guessed when I see the particular style and confusion: it's you isn't it? And so far I have been right. The particular author's magic has expired, and I see the same fault replicated everywhere he has been.

  • source
  • parent
  • hideshow 7 child comments
  • [–] 10 points 5 months ago (6 children)

    One of my coworkers is fond of using ternary expressions instead of "if" blocks. Even ones without an "else". So I see things like:

    condition ? someVar = "blah" : null;

    or

    condition ? doSomething() : null

    Which should both just use "if" statements. Or my favorite:

    condition ? someVar = "foo" : someVar = "bar"

    which should really be

    someVar = condition ? "foo" : "bar"

  • source
  • parent
  • hideshow 6 child comments
  • [–] 5 points 5 months ago* (4 children)

    UUUuuuuuh, I am not a programmer (you're going to say "thank god"), but...

    I sometimes even chain them. You can put yet another ternary operator in the else and keep going. You know, else-if.
    So anyway, I can get ternary operators spanning 2 - 3 lines.
    Oh, I also often have issues thinking of proper loops, so you'd see a few terribly used goto statements.

    Although I do remove ones that are obvious brain fart.
    For example, quite obvious

    void example(bool true_or_false){
        if(true_or_false){
            //code if true
        }
        else{
            //code if false
        }
        //other code
    }
    

    Well, I've already had my brain goof up even that once or twice. "How the fuck", you're asking?

    void example(bool true_or_false){
        if(true_or_false){
            goto if_true;
        }
        //code if false
        goto end_false_if;
    if_true:
        //code if true
    end_false_if:
        //other code
    }
    

    The brain-fart if-else.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 2 points 5 months ago (2 children)

    You need another goto end right before the end_false_if:, otherwise the false code will always run

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 5 months ago (1 child)

    I tested it, it works as it is.

    #include <stdio.h>
    #include <stdbool.h>
    
    void main(){
            bool true_or_false = true;
            if(true_or_false){
                    goto if_true;
            }
            printf("This code runs only if false.\n");
            goto end_false_if;
    if_true:
            printf("This code runs only if true.\n");
    end_false_if:
            printf("This code always runs.\n");
    }
    

    If true, it jumps to if_true, then runs other code. If false, the if gets skipped, if false code gets run, then it skips over if true code.

  • source
  • parent
  • hideshow 1 child comment
  • load more comments (-1 replies)