I stopped reading at #2. You are a junior developer and you have no business verifying standards. Mid function returns are BAD CODE. There should never be a return statement anywhere but at the bottom of a function. This was settled long ago but morons still do it.

SomeObject returnValue = null;if (id != 0)
returnValue = success();
return returnValue;

Now what is so goddamn hard about that? Yeah some will argue that this just makes the function bigger but this is a doggerel example that nobody would ever actually write; functions in real code are more substantial.

And your first example was so trite. Who the hell would do a ladder of else blocks like that?

Hey, Medium. Why would drivel like this rate an editor’s recommendation? This is first year rubbish. First month. I figured not to use early returns less than a year into being a dev at my first job.

As for code reviews, you probably had meetings for them which people came to straight from the printer, seeing the code for the first time and looking for superficialities. Like yours.

Come on, Medium, you shouldn’t even publish this simpleminded crap, much less recommend it for reading.

A few days ago someone recommended that developers learn to “think outside the box.” I am not kidding. That was an editor’s pick too.

To those who might respond, I will not answer debate about early returns. I’ve used exactly three in 25 years all in the exact same extreme circumstance. The matter is settled.

American Software Developer living in Vietnam. Classical musician (guitar, woodwinds), weightlifter, multilingual, misanthrope • XY

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store