There are three different category of Design pattern i.e.
- Creational Design Pattern : used for creating object in software design pattern.
- Structural Design Pattern : refer for structuring of object(s) in software design pattern.
- Behavioral Design Pattern : used for behavior of objects in software design pattern.
1. Creational Design Pattern
- Deal with one of the most commonly performed tasks in an OO application, the creation of objects.
- Support a uniform, simple, and controlled mechanism to create objects.
- Allow the encapsulation of the details about what classes are instantiated and how these instances are created.
- Encourage the use of interfaces, which reduces coupling.
2. Structural Design Pattern[table “” not found /]
3. Behavioral Design Pattern[table “” not found /]
4. Collectional Patterns
Collectional pattern primarily deal with group or collections of Object. It allow the definition of operations on collections of objects, which are follows:
One liner[table “” not found /]
Strategy Vs Template Method
Template Method job is to define the outline of an algorithm, but subclass do some of the work. It means , I ( Template) have more control over my algorithm and I don’t duplicate code. All the duplicate code put into super class so that all subclass share those code.
Strategy method use object composition while Template use inheritance. Click here Template Method Vs Strategy Design pattern
Who wraps object for what?
– Adapter: Wraps another object and provides a different interface to it.
– Decorator: wraps another object and provides additional behavior for it.
– Facade: wraps a bunch of objects to simplify their interface.
– Proxy: wraps another object to control access to it.