OOP Design Patterns
Object Oriented Programming (OOP) Design Patterns are defined
as reusable and tested solution for common object oriented design problems.
They allowed programs
to be maintainable, reusable, more flexible and loosely coupled.
Generally these OOP design patterns are divided into 3 categories
as Creational, Structural,
and Behavioral patterns.
Respective to those 3 categories, there are 23 object oriented
design patterns as shown in the given flow diagram.
Out of the above diagram we have pointed out 5 commonly used
design patterns.
· Singleton
This limits
creating a class only to one object.
This is
achieved through making the constructor as private to that class.
· Factory Method
Normally
objects are created without denoting the specific class to which they are created.
To overcome this issue, objects are created by calling a factory method without
calling to a constructor.
Declare
an interface to create an object, but subclasses will choose class to
instantiate.
· Builder
Builder
is used
to build objects.
Builder
separates construction of a complex object and representation
Its object
creation is same as abstract factory pattern but in builder pattern creation is
done in step by step whereas abstract factory pattern returns the object at
once.
· Adopter
It
allows the interface of an existing class to be used as another interface
Adapter
acts as a translator which enables communication
Suppose
output of one program is in XML format wants to feed to another which requires JSON
input, at that point we use an adapter in between in order to coordinate the
work.
Comments
Post a Comment