You are on page 1of 5

Factories

Summary and code


Factories

• Simple Factory

• Factory Method

• Abstract Factory
what is common between all Factories

• All of them serves the purpose of creating objects

• They hide the instantiation of objects —> encapsulate objects creation

• Their responsibility is to create objects


when to use each factory

• Simple factory:

• many implementations of product

• Factory method

• control the product creation and any process on the product

• Abstract factory

• uses the idea of the factory method but gives a framework to generate
group of related objects
Code

• download the code from the ams

• the folder contains three subfolders

• pizzasimplefactory

• pizzafactorymethod

• pizzaabstractfactory

You might also like