Identifying the aspects that varyBut the pressure is on to add more pizza typesEncapsulating object creationBuilding a simple pizza factoryReworking the PizzaStore classThe Simple Factory definedFranchising the pizza storeWe’ve seen one approach...But you’d like a little more quality control...A framework for the pizza storeAllowing the subclasses to decideLet’s make a PizzaStoreDeclaring a factory methodLet’s see how it works: ordering pizzas with the pizza factory methodSo how do they order?Let’s check out how these pizzas are really made to order...We’re just missing one thing: PIZZA!Our PizzaStore isn’t going to be very popular without some pizzas, so let’s implement themNow we just need some concrete subclasses... how about defining New York and Chicago style cheese pizzas?You’ve waited long enough. Time for some pizzas!It’s finally time to meet the Factory Method PatternThe Creator classesThe Product classesAnother perspective: parallel class hierarchiesFactory Method Pattern definedA very dependent PizzaStoreLooking at object dependenciesThe Dependency Inversion PrincipleApplying the PrincipleInverting your thinking...A few guidelines to help you follow the Principle...Meanwhile, back at the PizzaStore...Ensuring consistency in your ingredientsFamilies of ingredients...Building the ingredient factoriesBuilding the New York ingredient factoryReworking the pizzas...Reworking the pizzas, continued...Revisiting our pizza storesWhat have we done?More pizza for Ethan and Joel...From here things change, because we are using an ingredient factoryAbstract Factory Pattern definedFactory Method and Abstract Factory comparedTools for your Design ToolboxA very dependent PizzaStore