Hacker News new | past | comments | ask | show | jobs | submit login

There is something wrong about this.

Code is a tree, code is about nesting. If you do not like nesting, you do not like code.

Code is not 'text'. You do not read code top to bottom like text. Code has a structure, and you read that structure.

And if an example of 'improvement' doubles the line count, you have a pretty good indication you are doing something wrong.

What seems to have happened is a small piece of advice has been taken too far. The early-return shortcut is reasonable. It is indeed advocated by Fowler and Beck (who deserve some trust) -- they call it 'replace nested conditional with guard clauses'. But that is something very particular. It does not suggest removal of all nesting in general.




Just because code is a tree doesn't mean a deeper tree is better than a shallower one.




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

Search: