2
Xo-oY
7y

Is it normal that my lead developer insists that if(x){return A} else {return B} must be changed to if (x){return A} return B, and a variable must be renamed from requestFn to requestFunc because the former is confusing?

Comments
  • 4
    For me yes. He is right. You spend more time reading the code than writing it.. so it should be very clear.
  • 1
    @isawen thats bs... Rlly
  • 4
    Yes its called consistent code.

    Fn could mean tons of things. Now its clear, but what when the code is a year old, and someone has made fn a abbreviation for something unrelated. It will be a PITA to understand it.

    I came across a certain class called ScMsg. message is clear but Sc wasnt for me. Okay lets read the description in the comment
    "// the sc msg class", hmm that didnt help lets see the class itself then.

    Everywhere it says sc msg, no clue what it means from the class itself.

    Lets look at the usages.
    Hmm its only used in a file and only in combination with the variable ScMsgQ...

    After an hour of research and asking teammates nobody knows what it means...
  • 0
    Tis is why they call it bleed developer
  • 0
    The more code is one whole consistent thing the easier it is to read and understand it.

    No unnecessary else's are a great example of that
  • 0
    You misspelled requestFunk. Or did you mean requestFunction?
  • 1
    I would say your function should not have multiple exit points. But that’s all coding style, so there isn’t „the“ answer...
  • 0
    Do you really need hungarian notation? Have you considered that naming the function what it actually does resolves the need to insert the type into the name?
  • 0
    @RoodRallec thats true unless its a simple ifstatement
  • 0
    Hmm, I'm just wondering if Func is actually clearer than Fn, since Fn is used quite widely in computer to short for function, like on the keyboards, or jest.fn()
  • 0
    @Xo-oY it is if its a coding standard there, I assume it is since lead says so.
  • 0
    Would you say if (type==='json'){return response.Jason();} return response.text(); is more clear than if (type==='json'){return response.Jason();} else {return response.text();}? And it MUST BE changed to fit the first type? FYI the lead does not have this rule written anywhere, it's just something she does in "most projects"
Add Comment