47
Geoxion
79d

So my team lead told me in a code review that you shouldn't use 'else if' in code.
Instead you should best them like:
if
else
if
else
if
else

Apparently that would improve readability...
Am I crazy, or what?

Comments
  • 19
    Are you sure you didn't misunderstand ? That looks retarded.
  • 0
    @ItsNotMyFault Nope, he was serious. Even showed me how to change the code to be more to his liking and he did that.

    He also said he would do it in a completely different way, but still he preferred the nesting over some else ifs
  • 5
    Are you he didn’t meant sth like:

    If ... {return}
    If ... {return}
    ...
    return
    ?
  • 5
    Yes you are crazy, but your team lead is even more crazy
  • 0
    🤢🤮 „team lead“ means „dude who is dumb enough to tube for mean boss decisions“ not „lead a team“. So you better ignore him as much as you could. Ask him for internet source that proves his crap as „widely accepted“ in the dev community. 😉
  • 0
    @gintko nope, he typed it out on his screen
  • 1
    Oh, and I must say, generally I agree with his comments. But this one really stood out XD
  • 2
    How the fuck, it mixes layers. You have one layer of questions like it is apple? No maybe it is orange? Oh maybe then melon? No? So something else, ok then. After you know which fruit it is yku could ask about color or something and put it in next layer. Also it make that 1 layer switch of 6 cases will be 6 times nested if and a lot of nesting is bad for readibility...
  • 5
  • 1
    @BlazinDevilify Haha, I don't think he'd allow that either
  • 2
    @BlazinDevilify the most impressive thing about that are those closing parentheses 😂
  • 1
    @tuc0w ikr, have fun finding the missing bracket :D
  • 2
    Use a switch instead.
  • 2
    @C0D4 or a design pattern if possible
  • 4
    @BlazinDevilify That's awesome. Found this gem in the comments.

    Some dude writes:
    'It checks this.isFirefox twice.'
    Other dude replies:
    'Gotta be sure.'

    :'D
  • 0
  • 0
    "dupa" on the shitcode site is visible for everyone or just regional thing? 😃 I remember my first atempt to some kind of debugging with that "dopa" error message 😃
  • 0
    @BlazinDevilify 14 reasons why
  • 1
    @Omnisus for me it's also visible
  • 1
  • 1
    @BlazinDevilify thanks 😃 It means ass, but is use to express failure, too 😃 soft fuck
  • 0
    @Omnisus damn I'm getting old
  • 0
    @BlazinDevilify Polish word so maybe getting old isnt case 😃
  • 0
    You shouldn’t leave the if else statement without an else. From my experience you can
    If
    Else if
    Else if
    Else

    If its a method return, set values instead
    X =4;
    If something
    Set value

    Return x
  • 1
    @junners It seems like a cargo cult in programming to me to mutate a variable in a huge if else statement only to enforce one return statement per method.

    I rather would use early returns and avoid writing else statements altogether.

    If (cond) { return "Foo"}

    If (cond1) { return "Bar"}

    return "Default"

    Or in this very case a switch statement.
Your Job Suck?
Get a Better Job
Add Comment