34
hasnol
8y

Developers who writes something similar

if (count >= 0) { return true; }

else { return false; }

deserves a special room in hell.

Comments
  • 4
    Bit harsh, maybe. They just need their code reviewed and educated on how to be brief.
  • 1
    @samk I understand. But it's a recurring issue :( By the same people.
  • 2
    @shidi Then I think your only option is public flogging!
  • 3
    There's also those people who first create a separate variable to return after the if statement

    For no reason whatsoever
  • 1
    I'm too lazy to do such a thing
  • 3
    return count >= 0;
  • 2
    I personally do something like this
    if (statement)
    return 1;
    return 0;

    But I had a professor that liked it with an else for readability. He was a pain
  • 2
    That's not so bad... What's worse is stuff like this:

    List<String> list = new ArrayList<>();

    String v1 = "something";
    String v2 = "something else";
    list.add(v1);
    list.add(v2);
  • 2
    You wouldn't believe, how many people in my company do that. And all that code is pushed cleaning this. Thank God GoLint tells you when you're using useless else statements.
  • 0
    we use linters here for noobs. its like the first task in the CI so the build fails without even getting to the tests and build phase
  • 4
    a count can't be lesser than zero -.-
  • 4
    It could be worse...

    if (count >= 0) { return true; }
    else if (count < 0) { return false; }
  • 0
    I often saw this from unskilled developers:

    if(count($array) > 0){ ... }

    when it could just be

    if($array) { ... }
  • 0
    @shidi why don't you teach them the short hand version then?
  • 0
    @simeg because it's easier to rant about it
  • 0
    @cciamlazy @simeg I did for several times. But they keep repeating it.
Add Comment