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
  • Client

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. ...

Get AdvancED ActionScript 3.0: Design Patterns now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.