The Simple Factory
A Simple Factory encapsulates the conditional logic used to create a product. Figure 6-1 shows the class diagram.
Figure 6-1. Simple Factory class diagram
A Simple Factory has the following parts:
- Abstract product
- Concrete productt
- Concrete creatort
Its benefits are as follows:
- Conceals the logic of product creation
- Only deals with the product interfaces
It also has this drawback:
- Lacks the flexibility to change (change is a constant)
A Comprehensive Look
Simple Factory isn't a design pattern, but it needs to be included in this chapter because the Factory Method design pattern uses what resembles a simple factory. ...