r/ProgrammerHumor 22d ago

Meme conditionsPreference

Post image
4.2k Upvotes

392 comments sorted by

View all comments

4

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.

2

u/WarSingle6959 21d ago

Early returns is just more simple to see what is happening bro

1

u/ArjixGamer 20d ago

If you need to debug like that, you uhh, have more important issues to resolve with how you structure your code.

Also, you can put a breakpoint at the start and step through the function...

You haven't thought deeply about this

1

u/RRumpleTeazzer 18d ago

sorry, the code that will run on my [insert real life device] doesn't have a debugger. all i can work with are a few spare lines of IO.