43
Geoxion
6y

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
    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
  • 1
    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...
  • 0
    @BlazinDevilify Haha, I don't think he'd allow that either
  • 1
    @BlazinDevilify the most impressive thing about that are those closing parentheses 😂
  • 2
    Use a switch instead.
  • 2
    @C0D4 or a design pattern if possible
  • 3
    @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
    "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
  • 0
    @BlazinDevilify thanks 😃 It means ass, but is use to express failure, too 😃 soft fuck
  • 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
  • 0
    @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.
Add Comment