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 Factory Method Pattern

The Factory Method pattern encapsulates creational logic in subclasses, allowing them to infer their own implementations. Figure 6-2 shows the class diagram.

Image

Figure 6-2. Factory Method pattern class diagram

This pattern has the following parts:

  • Abstract product
  • Concrete product
  • Abstract creator
  • Concrete creator
  • Client

The pattern's benefits are as follows:

  • Factory methods eliminate the need to bind application-specific classes into your code.
  • The code only deals with the product interfaces.

It also has this drawback:

  • Sometimes subclasses can't be created.

A Comprehensive Look

The Factory Method pattern lets ...

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