I have successfully used strategy design pattern to for a Ducks Class and its Subtypes. Below is the diagram of relationships between different classes.
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.
Between the options you gave, I would go with factory class to get duck instances on some options.
But I would suggest considering builder pattern here.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.