Chapter 5. Factory and Template Method Patterns


In This Chapter

Abstract Classes 75

Template Method 76

Factory Method 78

Summary 81

When creating groups of related classes, it's important to maintain those relationships during object creation. One way to do this is with the Factory Method design pattern. The Factory Method pattern is a creational pattern and solves the problem of creating objects without specifying a concrete type. This is most often used in abstract classes that define a method for object creation. Subclasses can then override this method to define the specific object to be created.

The Factory Method is most often used in conjunction with another pattern called the Template Method. To better understand the Factory Method and provide more context for this solution, we'll also look at the Template Method in this chapter. Because the Factory Method uses and then builds on many of the same concepts, we'll look at the Template Method first.




Advanced ActionScript 3 with Design Patterns
Advanced ActionScript 3 with Design Patterns
ISBN: 0321426568
EAN: 2147483647
Year: 2004
Pages: 132

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net