DESIGN PATTERNS.
Design patterns provide a comprehensive solution that can be reused for common problems that arise in software design. A design pattern isn’t a complete design that can be transformed directly into code.
Types of Design Patterns:
- Creational Design Patterns
Creational Patterns deal with object creation mechanisms, trying to create objects in a manner suitable to the situation. They reduce complexity and instability by creating objects in a controlled manner.
Types of CDP:
Creates families of related dependent objects.
Constructs complex objects using step-by-step approach.
Creates an instance of several derived classes.
Creates a new object from an existing object.
A class of which only a single instance can exist.
- Structural Design Pattern
These design patterns are concerned with arranging different classes and objects to create larger structures and provide new functionality. Structural class-creation patterns use inheritance to create interactions/interfaces.
Types of SDP:
Allows for two incompatible classes to work together by wrapping an interface around one of the existing classes.
Separates the outline so that the two classes can differ on their own.
Composite patternconsider a group of objects to be one.
Provides a simple interface to a more complex underlying object.
Flyweight pattern takes the weight, or memory footprint, off of our objects by recycling them.
This pattern offers a proxy, or a substitute, to another complex object. Provides a space interface for the primary object to control access, reduce costs, or reduce complexity.
- Behavioral Design Patterns
Behavioral patterns are about identifying common patterns of communication between objects and identifying these patterns.
Types of BDP:
Delegates commands to a chain of processing objects.
Creates objects which encapsulate actions and parameters.
Implements a specific language.
It accesses the elements of an object in sequence without revealing its basic representation.
Allows for free integration between classes as it is the only class that has in-depth knowledge of their methods.
Provides the ability to restore an object to its previous state.
Is a publish/subscription pattern that allows a number of observer objects to see an event.
Allows an object to change its behavior when its internal state changes.
Allows one of a family of algorithms to be selected on-the-fly at run-time.
Defines the framework of the algorithm as an abstract class, allowing its sub-classes to deliver consistent behavior.
Separates an algorithm from an object structure by moving the hierarchy of methods to a single object.
REFERENCE
- https://www.geeksforgeeks.org/design-patterns-set-1-introduction/
- https://sourcemaking.com/design_patterns
From the blog CS@Worcester – THE SOLID by isaacstephencs and used with permission of the author. All other rights reserved by the author.