DEV Community

loading...

Discussion on: Write better code and be a better programmer by NEVER USING ELSE statements

Collapse
entomy profile image
Patrick Kelly

While I agree with many of these points, and definitely find excessive cases of indentation in more novice-written code, this reads far more like "do as I say because I do it this way". You even start this with gloating that fits right with that motivation. Do you have studies on readability and how this change impacts that? While I suspect it does increase it, the wording of your article goes against your intentions.

Collapse
dglsparsons profile image
Douglas Parsons Author

Hi. Thanks for the feedback. That's not my intent at all, but I'm sorry it's come across that way. It's more intended to be - this is what works in my experience but I appreciate your perspective.

I'll bear this in mind in future :)

Collapse
entomy profile image
Patrick Kelly

I didn't think it was, hence saying I agree with your point. I just saw an easy way others can discredit your message and I don't think it's a message that should be discredited. I'm glad hostility didn't come through in text, because my intentions were only constructive.

Collapse
kant2002 profile image
Andrii Kurdiumov

You can look at how people talk when explaining something. I apply same technique and find it very useful. My motivation for this technique and some other comes from psychology and some linguistics. My coworkers whom I mentor think this is valuable technique, but maybe they do not know better. I cannot find studies regarding applicability of the technique in the real world even if I look for it deliberately. If you know what entity can do such kind of research I’m more then happy to start search again to prove or disprove statements of an article.

My anecdotal evidence is that code written in such way easier for novices to follow, since this kind of code can be easier to reading out loud and it would appear more natural.

Also there usually when express business logic there two kind of code intermixed, guards and shortcuts which require early exit to simplify logic and actual business logic where this rules less strictly applicable.

Why early exits and shortcut processing important? Try to remember how rare cases handled by business persons(can be engineers from other fields). Most people concentrate on core process and for other conditions usually throw simple shortcuts and suggestions which solve problem from their perspective. Such style of code just reflect how business people usually talk, just in slightly more formal way