5 ms·
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
by arialdomartini 26d ago
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".
- AdieuToLogic 26d agoAnother 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.
- what 26d agoSo you’ll make a two line function to replace a braced block? Seems kind of unhinged.
- arialdomartini 25d agoIt may happen. I guess you agree that most of the times conditional blocks exist they are more than 2 lines.
- farlight 25d agoThe "Uncle Bob" school of thought follows this pattern. Look at his projects, I personally find them unreadable. https://github.com/unclebob/fitnesse https://github.com/unclebob/fitnesse