• 3 Posts
  • 124 Comments
Joined 1 year ago
cake
Cake day: July 5th, 2023

help-circle


  • Avid Amoeba@lemmy.catoProgrammer Humor@lemmy.mlMeetings vs productivity
    link
    fedilink
    arrow-up
    11
    arrow-down
    2
    ·
    edit-2
    8 days ago

    I’m serious. Politics are a good chunk of the job, meetings is a major place for that. What happens there can have dramatic effects on how long something takes and therefore on the “produced output per unit of time.” I’ve been at it for 13 years now and embracing that has had positive results on my well-being and career. 🥹













  • Have you stopped to consider why you can’t explain it better? Perhaps the reason is because you’re wrong.

    Yes I have. You’ve already assumed I’m not too bright more than once and worked from there. There’s no point in investing more work on my end. If what I said worked, good. If not, that’s fine too.



  • Avid Amoeba@lemmy.catoProgrammer Humor@lemmy.mlgot him
    link
    fedilink
    arrow-up
    3
    ·
    edit-2
    2 months ago

    Yes clearly someone has to read the blocks at least once to ensure they are correct.

    In subsequent reads, when I’m interested in the second block out of two, say during a defect analysis, I don’t have to read the first one to be sure I’m going to reach the second. I can straight head for the second one and any subsequent stuff I care about. Multiple returns force me to read both blocks. I don’t know what else to tell you. To me this is obvious and I think it’s probably even provable. I don’t know about you but I have to read a lot of existing code and every bit helps. We have pretty strict code style guides for that reason.



  • Avid Amoeba@lemmy.catoProgrammer Humor@lemmy.mlgot him
    link
    fedilink
    arrow-up
    4
    ·
    edit-2
    2 months ago

    Not sure why you had to do the inverted predicate check again in your first example. You already have the information encoded in the value of retval. It can be written like this:

    int result = 0;
    if (!p1) result = -ERROR1;
    if (p2) result = -ERROR2;
    if (!p3 && p4) result = -ERROR3;
    if (result != 0) {
        result = 42;
    }
    
    return result;
    

    With a return value you have to add 4 extra lines. This overhead remains constant as you add more checks and more business logic.

    Yes all the other suggestions are better than early returns in business logic and would help with leaks. Would be nice if we had RAII outside of C++. I think Rust has it? Haven’t done Rust yet.