484
got him (lemy.lol)
submitted 7 months ago by ngn@lemy.lol to c/programmerhumor@lemmy.ml
you are viewing a single comment's thread
view the rest of the comments
[-] ZILtoid1991@lemmy.world 33 points 7 months ago

Why is multiple levels of indentation bad?

IDK, but if the reason is "to break stuff into multiple functions", then I'm not necessarily writing yet another single-use function just to avoid writing a comment, especially in time critical applications. Did that with a text parser that could get text formatting from a specifically written XML file, but mainly due to it being way less time critical, and had a lot of reused code via templates.

[-] frezik@midwest.social 21 points 7 months ago

It's important to remember that Linus is primarily writing about C code formatting. C doesn't have things that tend to create more deeply nested structures, such as a formal class syntax, or nested functions.

Going too deep is still bad--as zea notes, it's an indication of control structures run amok--but the exact number is dependent on the language and the context.

[-] diviledabit@startrek.website 1 points 7 months ago

And you never include the switch-case-block indentation levels.

load more comments (2 replies)
this post was submitted on 09 May 2024
484 points (100.0% liked)

Programmer Humor

32742 readers
449 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS