|
|
|
|
|
by kbenson
3436 days ago
|
|
> aversion to certain shortcuts like ternary operators. > They don't understand that unclear code is probably the number one cause of technical debt. At the same time, verbosity can have an obfuscation quality all of its own. For simple assignment, I find a ternary operator very clear and concise, and much preferable to a 5-9 line (depending on style) if/else for a simple assignment. It also might keep you from using the single statement version of if/else if your language supports it, and that's probably justification in itself given how many problems that's caused in the past. Specifically, I think: usefulMetric = wantComplexCalc ? complexCalc(foo)
: simpleCalc(foo);
is preferable to: if ( wantComplexCalc ) {
usefulMetric = complexCalc(foo)
} else {
usefulMetric = simpleCalc(foo)
}
even if only because it doesn't obscure intent with what is essentially boilerplate. |
|