Yeah I understand why you think so. Switch case is just to select a suitable strategy and not to return any specific object implementation like we do in a factory.
@@brunocastro754 Agreed mate. I would have a class that will enumerate all the strategy and then invoke it in the code via DI. Hence not breaking any OCP.
Correct me if I'm wrong.. When u start using switch case then its more like factory.. Strategy should remove that switch case..
Yeah I understand why you think so. Switch case is just to select a suitable strategy and not to return any specific object implementation like we do in a factory.
@@CodeRadianceYou could use reflection to pick the appropriate strategy at run time.
@@starman9000I wouldn't use reflection because it's too costly for that, not to mention the increased complexity and worse maintainability.
@@brunocastro754 Agreed mate. I would have a class that will enumerate all the strategy and then invoke it in the code via DI. Hence not breaking any OCP.
lol! it says simplest strategy but u just used a very complex and overwhelming example
thanks