Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Incidentally, I'm from the opposite school and consider every “if” followed by a braced block a smell. If a conditional body needs a block, it's doing enough to deserve a name, so I promote it to a single named call, à la "Extract till you drop".


Another phrase for this is "functional decomposition", which usually is a good thing.

Better yet is to identify conditional execution paths as early as possible in order to obviate conditionals in the call tree. For example, identifying a "create a new something" verses an "update an existing something" based on the workflow initially invoked greatly simplifies service and/or persistent store logic.


So you’ll make a two line function to replace a braced block? Seems kind of unhinged.


The "Uncle Bob" school of thought follows this pattern. Look at his projects, I personally find them unreadable.

https://github.com/unclebob/fitnesse


It may happen. I guess you agree that most of the times conditional blocks exist they are more than 2 lines.




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

Search: