- this is basically suitable for single instance through out the program.
- it can contains the static variables used by the program.
- the benefits for this versus global variable is for data encapsulation purpose. You can have accessor and modifier functions as a guarding to set or read the variable.
- The factory is a class to hold and control the creation of the class objects.
- The object class held by factory is the base class, thus any of the child class object can be instantiated, and transparent in the main program.
- Abstract Factory
- Similar to Factory type, but the factory is an abstract class.
- This is good for multi-platform support, where the right factory will be instantiated based on the platform.
- This is to hide the complexity of the object by the builder.
- The program can have multiple builder with same operation but different methods.
- There is a “directory” to call the right builder to call for operation to produce “product”.
- Using abstract class to force the functions overidding (enforcement on the child classes)
- Thus the child classes need to have the implementation for the functions specified by the base class (the prototype abstract class)
Thursday, November 3, 2011
Design Pattern : creation
Subscribe to: Post Comments (Atom)
Post a Comment