3 ms·
The first version references them to allow for a single point of refactoring to increase the number of command messages or status messages (the valid_xxxx_messa
by spott 10y ago
The first version references them to allow for a single point of refactoring to increase the number of command messages or status messages (the valid_xxxx_message() function call). He recognizes this as a not ideal and then refactors the code to have both the benefit of the jump table created by the switch statement and the benefit of the if statement (the single point of refactoring).
- delinka 10y agoI see now. If we add to the `enum`s and forget to update our `switch`, we still get the chance to process new commands, albeit with a minor performance hit. Personal opinion: Unit tests should be used to let you know when you forgot to add in new `case`s.