Tuesday, April 17, 2007

Prototype

In Abstract Factory, the different styles of products are realized in different subclasses of Abstract Factory. Though it is commonly desirable, when mixing different styles together, it is limited. What's more, it leads to too many subclasses. Prototype provides a way to eliminating unnecessary subclassing by adding a Clone() interface. This function is simply a copy constructor. Usually we have an auxiliary Prototype factory/manager (Client) that is instantiated with needed prototypes and produce the demanded parts by calling Clone().

What's more, by changing the Prototype manager dynamically, the products can also change dynamically and locally (which means only part of the products changes).

No comments: