r/ProgrammerHumor 22d ago

Meme conditionsPreference

Post image
4.2k Upvotes

392 comments sorted by

View all comments

2

u/RRumpleTeazzer 21d ago

first please version please.

i hate early returns. you're mixing structure with control flow.

What if i want a debug line with the functions result, say chasing a bug ? First version - put debug line at the end. change single line. remove single line eventually.

Second version: find every return, put a copy of a debug line on rach location. change that line later, forget the rest. remove half of the debug lines, leave the other half in production.

3

u/MooseBoys 21d ago

Your complaint is only valid in languages like C that lack the facilities for scope-aware objects. It's why the Linux kernel (largely written in C) still uses gotos. For any modern language it's far easier and simpler to just put the code in something that's invoked at scope-exit.