mercredi 6 décembre 2017

Factory Design Pattern - Which class should I use to create a Factory

I have successfully used strategy design pattern to for a Ducks Class and its Subtypes. Below is the diagram of relationships between different classes.

enter image description here

Now, I want to create a Factory to generate instances of different types of ducks. Should I use behavior classes (FlyBehavior and QuackBehavior) or should I use just Duck class to create a Factory class? Thanks. Your help will be appreciated.

Aucun commentaire:

Enregistrer un commentaire