February 7, 2017

[HDGEM] A better approach to avoid using a switch or multi-conditional if-else-if is to use the Strategy pattern.

Converting switch or multi-conditional statements to Strategy pattern


Strategy pattern allows us to have a separate class for each case. We can then add new case more easily.

In addition, having smaller classes means that my unit testing becomes more focused on testing one particular situation.

--
Posted By Blogger to HDGEM at 2/07/2017 07:05:00 AM
Post a Comment

Featured Post

The new Dell XPS 13’s overall design is 30% thinner and lighter than its predecessor

The new Dell XPS 13 has twice the performance of the XPS 13 launched in 2015, as well as improved battery life that should enable the model...