A design patterns are design patterns that identify common communication patterns between objects and realize these patterns.
- Architecture - Iterator Design Patterns
- Architecture - Observer Design Patterns
- Architecture - Command Design Patterns
- Architecture - Strategy Design Patterns
- Architecture - State Design Patterns
- Architecture - Template Method Design Patterns
- Architecture - Chain of Responsibility Design Patterns
- Architecture - Mediator Design Patterns
- Architecture - Interpreter Design Patterns
- Architecture - Memento Design Patterns
- Architecture - Visitor Design Patterns
- Architecture - Null Object Design Patterns
Sequentially access the elements of a collection
Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.
Mainly used to implement distributed event handling systems.
A way of notifying change to a number of classes
In Object Oriented Programming world each and every object is responsible for its own functionalities and sometimes one object needs to depend upon anther object. If we implement logic (tight coupling) in one object (observer) to monitor or track of another object (source) functionality, it will make tight coupling dependency between these 2 objects. If any changes need to be done in source object requires making changes in target object (observer).
We should allow loose coupling (no one object depends upon other objects functionality) between the objects. Every object should take care of its functionality and if we need any information from another object it should notify automatically.
Types of a pattern:
Subject, Observer Model:
A design pattern in which an object called the subject, maintains a list of its dependents called observers and notifies them automatically of any state changes, usually by calling one of their methods.
Reference Example 2- Maintain subject Reference
Publisher, Subscriber Model:
A design pattern in which an object called the publisher, maintains a list of its dependents called subscribers and notifies them automatically of any state changes, usually by calling one of their methods.
Reference Example 1 - Using Delegates - Register subscriber
Encapsulate a command request as an object
Encapsulate a request as an object,
thereby letting you parameterize clients with different requests, queue or log requests, and
support undoable operations.
Alter an object's behavior when its state changes
Defer the exact steps of an algorithm to a subclass
Define the skeleton of an algorithm in an operation, deferring some steps to subclasses.
Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.
A way of passing a request between a chain of objects
- Avoid coupling the sender of a request to its receiver
- by giving more than one object a chance to handle the request.
- Chain the receiving objects and pass the request along the chain until an object handles it.
Defines simplified communication between classes
Define an object that encapsulates how a set of objects interact.
Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.
A way to include language elements in a program
Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.
Capture and restore an object's internal state
Defines a new operation to a class without change
Represent an operation to be performed on the elements of an object structure.
Visitor lets you define a new operation without changing the classes of the elements on which it operates.
Designed to act as a default value of an object