I am just going through the wiki pages of Factory Method Pattern and Abstract Factory method pattern.
From Head First Design Patterns I got this
Factory method Pattern uses inheritance, Abstract Factory Pattern uses composition. Abstract Factory Pattern also does the same like Factory Method Pattern which keeps the Clients decoupled from concrete Types but in a different way.
After analyzing the wiki examples, I couldn't actually find the composition in the examples. Both of the Patterns uses inheritance.
Factory Method Pattern
Abstract Factory Pattern
Here are my questions.
- Does Factory Method Pattern always have just only one Abstract Product inheritance tree unlike Abstract Factory Method Pattern?
- Where could be composition utilized or programmed in a way? If it's just the Client with main method, then Factory Method Pattern also uses Composition. A code snippet example would clear the concept.
- Is my interpretation of these patterns as in sample sketch correct?
Aucun commentaire:
Enregistrer un commentaire