Design Patterns · Middle · Question 5 of 75
When is an Abstract Factory appropriate instead of a simple factory?
- ✓Correct answer: When you need families of related, compatible objects
- 2When you need to create objects without calling a constructor at all
- 3When an object must exist as a single instance
Explanation
Example: a UI kit for two platforms - the factory creates a button, an input and a modal in one style, and they can't be mixed. A simple factory picks one product by a parameter. Don't introduce an abstract factory if there's only one family.