Design Patterns
Creational Design Patterns
Creational Design Patterns
Creational design patterns deal with object creation mechanisms, trying to create objects in a manner suitable to the situation. The basic form of object creation could result in design problems or added complexity to the design. Creational design patterns solve this problem by somehow controlling this object creation.
There are several types of creational design patterns, including the singleton, factory, builder, prototype, and abstract factory patterns.
- The singleton pattern ensures that a class has only one instance, and provides a global access point to it.
- The factory pattern provides an interface for creating objects in a super class, but allows subclasses to alter the type of objects that will be created.
- The builder pattern separates the construction of a complex object from its representation, allowing the same construction process to create various representations.
- The prototype pattern creates new objects by copying existing objects, which can be used as a starting point for creating new objects.
- The abstract factory pattern provides an interface for creating families of related or dependent objects, without specifying their concrete classes.