Design Pattern - Creational Flashcards
Abstract Factory
Works around a super-factory which creates other factories. This factory is also called a factory of factories. It is an interface that is responsible for creating a factory of related objects without explicitly specifying their classes. Each generated factory can give the objects as per the Factory pattern.
Builder
Builds a complex object using simple objects and using a step-by-step approach. This builder is independent of other objects.
Factory Method
One of the most used design patterns in Java. Create objects without exposing the creation logic to the client and refer to the newly created object using a common interface.
Object Pool
Avoid expensive acquisition and release of resources by recycling objects that are no longer in use.
Prototype
Refers to creating duplicate objects while keeping performance in mind. Involves implementing a prototype interface which tells to create a clone of the current object. This pattern is used when the creation of an object directly is costly. For example, an object is to be created after a costly database operation. We can cache the object, returns its clone on the next request, and update the database as and when needed thus reducing database calls.
Singleton
A single class responsible for creating an object while making sure that only a single object gets created. This class provides a way to access its only object which can be accessed directly without the need to instantiate the object of the class.