Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
We don't write 'else' blocks (infobip.com)
7 points by thunderbong on Aug 9, 2024 | hide | past | favorite | 3 comments


Reminds me of Christopher Seiwald's seven principles, one of which was… as I recall… get rid of unusual paths at the top of the function, then have the main body unindented, looking as if it's the main part, not indented.

https://www.eetimes.com/seven-pillars-of-pretty-code has it differently. The one I mean is the last, described very differently.


I have a serious question - is “clean code” an opinion, or something rooted in actual theory and principles?


As near as I can tell, what exactly constitutes "clean code" is an opinion, but the concept in the abstract is rooted in actual theory and principles.

Personally, I think the main thing isn't the exact coding standards a place uses, but that there are coding standards being adhered to. Consistency across the codebase is more valuable than exactly what that consistency looks like.

In the case of this article, I think that that the argument against using 'else' blocks is pretty weak -- but having a company-wide standard that ensures code consistency is valuable enough that if I worked at a place with such a rule, I'd be fine adhering to it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: