Oct 10, 2018

[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