lundi 6 juin 2016

Is 'Strategy Design Pattern' no more than the basic use of polymorphism?

In Strategy Design Pattern, what we do is

  • Create a common interface.
  • Implement a set of classes using that interface with overridden method(s).
  • Let the run time to choose the actual class for an object which has the same type with that common interface and call the overridden method(s) which will resolve correctly according to the class.

My question isn't it the basic example of polymorphism and method overriding we learn?

other than the possibility of using an abstract class too, replacing the common interface.

Aucun commentaire:

Enregistrer un commentaire