System Design
15. Software Design PatternsAnimated walkthrough
Abstract Factory Pattern
Create families of related objects.
The idea
A factory interface produces matching products, such as a UI toolkit for dark or light themes.
Watch it work
The steps light up one at a time. Use the controls to pause or step through.
- 1Define product interfaces
- 2Create a factory per family
- 3Client asks the factory
- 4Products match
1/4
Step by step
- 1Define product interfaces
- 2Create a factory per family
- 3Client asks the factory
- 4Products match
Where it is used
Cross-platform toolkits.
Watch out for
Adding a new product type changes every factory.