General reusable solutions to common problems in software design.
Creational: Create objects while hiding the creation logic, rather than instantiate objects directly using new operator
Structural: are concerned with how classes and objects are composed to form larger structures. This is all bout class and object composiiton.
Behavioral: interaction/communication between objects.
Creational: Create objects while hiding the creation logic, rather than instantiate objects directly using new operator
Structural: are concerned with how classes and objects are composed to form larger structures. This is all bout class and object composiiton.
Behavioral: interaction/communication between objects.
- Creational
- Singleton: This pattern ensures that a class has only one instance.
- Factory Method: In Factory pattern, we create object without exposing the creation logic
- Abstract Factory patterns acts a super-factory which creates other factories. This pattern is also called as Factory of factories. In Abstract Factory pattern an interface is responsible for creating a set of related objects, or dependent objects without specifying their concrete classes.
- Builder pattern builds a complex object by using a step by step approach. Builder interface defines the steps to build the final object. This builder is independent from the objects creation process. A class that is known as Director, controls the object creation process.Moreover, builder pattern describes a way to separate an object from its construction. The same construction method can create different representation of the object.
- Prototype pattern is used to create a duplicate object or clone of the current object to enhance performance. This pattern is used when creation of object is costly or complex.
- Structural
- Adapter : convert the interface of a class into another interface client expect Related patterns: Repository, Strategy, Facade, Adapter pattern: convert the interface of a class into another interface client expect
- Bridge:
- Adapter starts from letter 'A' - map with After and Bridge starts from letter 'B' map with Before.
- Now when its Adapter its always to deal with the situation when some implementation is already in place and but some kind of hack
- or patch or connector to put in place to make it work, like the real (electric) adapter.
- Where in bridge - its before hand - design should be such that interface and implementation both are independent
- so abstraction is covered at interface level but actual implementation differs based on condition or need.
- Behavioral
- TemplateMethod: Define the skeleton of an algorithm in an operation, deferring some steps toSubclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the Algorithm's Structure.
- Strategy:There are common situations when classes differ only in their behavior. For this cases is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime.
- Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.

