Abstract Factory Pattern
Abstract Factory Pattern Intent Provide an interface for creating families of related or dependent objects without specifying their concrete classes. Also known as “Kit” Motivating example A UI toolkit wants to support multiple looks and feels for their widgets, and need to create UI widgets of consistent look.
Back to PizzaStore For pizzas of different regions, the same ingredients are made differently. NY pizza should use NY style ingredients
Ingredient Factory
Implement Ingredient Factory
Rework the Pizza
A Concrete Pizza
Revisit PizzaStore
Abstract Factory
Note Abstract Factory pattern uses Factory Method pattern to create concrete product Abstract Factory create families of products that belong together When product need to be added or removed, the factory interface needs to be changed
Dependency Inversion Principle Depend on abstraction, do not depend on concrete classes.