Saturday, February 1, 2020

Clean Code: G27: Structure over Convention

Enforce design decisions with structure over convention. Naming conventions are good, but they are inferior to structures that force compliance. For example, switch/cases with nicely named enumerations are inferior to base classes with abstract methods. No one is forced to implement the switch/case statement the same way each time; but the base classes do enforce that concrete classes have all abstract methods implemented.

https://moderatemisbehaviour.github.io/clean-code-smells-and-heuristics/#g23-prefer-polymorphism-to-if-else-or-switch-case

No comments:

Post a Comment