The Creational Patterns deals with the best possible way of
creating an object or an instance of a class. They simplify object creation
and provide a flexible approach towards object creation. The following are the
sub-patterns that fall under this group.
·
Abstract Factory
·
Factory
·
Builder
·
Prototype
·
Singleton
Both the Abstract Factory and the Factory pattern have the
same intent. They have the same names and do the same thing. It is only the
way that they operate that is important. Both the Abstract Factory and the
Factory pattern deal with the creation of an object. The difference being that
the Abstract Factory pattern uses objects to manage object creation while the
Factory pattern does the same using inheritance. The Abstract Factory pattern
provides an interface for creation of a family of related objects, but without
specifying their concrete classes. The Factory pattern also provides an
interface for the creation of objects, but allows the inherited classes to
decide on the appropriate time of these instantiations.
The Builder Pattern is one that isolates the construction of
a complex object from its representation, thus ensuring that several different
representations can be created depending on the requirements. The Prototype
Pattern allows an initialized and instantiated class to be copied or cloned to
create new instances rather than creating new instances. The Singleton Pattern
indicates that there can be only one instance of a class throughout the
Application’s life cycle. A singleton class is one that can be instantiated
only once in the application domain and provides a global point of access to
it.