0
Заплановано
Refactoring: Ternary Statements: Using Ternaries for their Side Effects
I think a great addition to the Conditionals portion of the Refactoring Guides would be to discourage using Ternary Expressions as Statements. This is highly discouraged, and you don't see it often, but it's been known to be present in some very, very legacy code. I've witnessed certain devs finding it in legacy code and using it because it's novel, and it tends to add to code clutter and can severely increase cognitive load when sifting through complex conditionals.
Example:
DON'T:
const foo = "bar"; foo === "bar" ? quux() : zim();
DO:
const foo = "bar"; if (foo === "bar") { quux() } else { zim(); }
Служба підтримки клієнтів працює на UserEcho
- Don't use Ternary Expressions as Statements
Hi!
This is a good one. I'll add it to my todo.
Thanks!