O'Reilly logo

AdvancED ActionScript 3.0: Design Patterns by Ben Smith

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required