clean-code-javascript
clean-code-javascript copied to clipboard
Add info to "Avoid conditionals" about smelly code and open/closed principle
I don't think that the provided info about why not use switches in this section is complete. Maybe we should add info about smelly code, the strategy pattern and open/closed principles.
In this speak/presentation it is all made clear why not using switches. And it has not so much to do with functions doing on thing, but more about the open/closed principle and that with adding/removing/editing one case you just "touched" all cases in the switch and all have to be tested again.
Also he added a example using the strategy pattern to refactor the switch without violating the "open/closed principle". I like that example very much.
Up for a PR if you have time? 😄