Академический Документы
Профессиональный Документы
Культура Документы
1. Behavioral,
2. Creational, and
3. Structural
“Factory Pattern defines an interface for creating the object but let the subclass
decide which class to instantiate. Factory pattern let the class defer instantiation to
the sub class “
3. Singleton Pattern
Singleton Design Pattern ensures that there is only one instance of a class
and provides global point of access to it.
4. Prototype Pattern
Prototype pattern refers to creating duplicate object while keeping performance in mind.
This type of design pattern comes under creational pattern as this pattern provides one
of the best ways to create an object.
When we talk about object creation we can find a better way to have new objects:
cloning
Clone () is a method in the Java programming language for object duplication.
5. Builder Pattern
Builder pattern builds a complex object using simple objects and using a
step by step approach.
This type of design pattern comes under creational pattern as this pattern
provides one of the best ways to create an object.
A Builder class builds the final object step by step. This builder is
independent of other objects.
The performance because it reuses the already created objects instead of creating new
ones. Example: Creating a database connection is a costly operation. So, it will try to use the
already existing database connections. Objects in the pool have a lifecycle:
creation, validation and destroy.
2. Structural design patterns
They deal with how classes and objects deal with to form
large structures.
Structural Design patterns use inheritance to compose
interfaces or implementations.
1. Adapter Pattern
Adapter pattern convert the interface of the class into a form what client
expects. Adapter let the classes work together which couldn’t otherwise due
to incompatible interfaces.”
Type of Adapters:
Object Adapters
Class Adapters
2. Bridge Pattern
3. Composite Pattern
4. Decorator Pattern
5. Facade Pattern
Facade Pattern says that just "just provide a unified and simplified interface to
a set of interfaces in a subsystem, therefore it hides the complexities of the
subsystem from the client".
In other words, Facade Pattern describes a higher-level interface that makes the
sub-system easier to use.
Practically, every Abstract Factory is a type of Facade.
6. Flyweight Pattern
A Flyweight Pattern says that just "to reuse already existing similar kind of
objects by storing them and create new object when no matching object is
found".
7. proxy Pattern
So, we can perform many operations like hiding the information of original object, on
demand loading etc.
In these design patterns,the interaction between the objects should be in such a way
that they can easily talk to each other and still should be loosely coupled.
That means the implementation and the client should be loosely coupled in order to avoid
hard coding and dependencies.
2. Command Pattern
3. Interpreter Pattern
4. Iterator Pattern
5. Mediator Pattern
A Mediator Pattern says that "to define an object that encapsulates how a set of
objects interact".
6. Memento Pattern
A Memento Pattern says that "to restore the state of an object to its previous state".
But it must do this without violating Encapsulation. Such case is useful in case of
error or failure.
7. Observer Pattern
"Just define a one-to-one dependency so that when one object changes state, all its
dependents are notified and updated automatically".
8. State Pattern
A State Pattern says that "the class behavior changes based on its state". In State
Pattern, we create objects which represent various states and a context object
whose behavior varies as its state object changes
9. Strategy Pattern
Template Pattern
1. A Template Pattern says that "just define the skeleton of a function in an operation,
deferring some steps to its subclasses".
Visitor Pattern
2. Null Objec