Come up with your puzzles in programming and get the answers.
Monday, October 15, 2007
Is Strategy Pattern any different than Polymorphism of OOPs
I am not sure if Strategy ( or Policy ) pattern is any different than simple use of Polymorphism with Encapsulation of OOPs theory. So why should it be a part of GoF Design Pattern. Comments welcome Cheers, Siddhartha
You are perfectly right in saying that Strategy is nothing but simple use of polymorphism. The reason for having a design pattern would have been triggered based on the usage. Polymorphism is a OO concept which could be applied to different situations as required and Strategy I feel is one such requirement where the kind of implementation (algorithm) required is chosen on the fly. Hence it is classified under behaviour pattern. In some sense, the Bridge Pattern also similar to Strategy as the class diagram for both the patterns look similar. This could be considered as another application of polymorphism , where the intent is to decouple the implementation from its abstraction.
1 comment:
You are perfectly right in saying that Strategy is nothing but simple use of polymorphism. The reason for having a design pattern would have been triggered based on the usage. Polymorphism is a OO concept which could be applied to different situations as required and Strategy I feel is one such requirement where the kind of implementation (algorithm) required is chosen on the fly. Hence it is classified under behaviour pattern. In some sense, the Bridge Pattern also similar to Strategy as the class diagram for both the patterns look similar. This could be considered as another application of polymorphism , where the intent is to decouple the implementation from its abstraction.
Am I making any sense ?
Post a Comment