The Simple Factory

A Simple Factory encapsulates the conditional logic used to create a product. Figure 6-1 shows the class diagram.

Image

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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.