Catalog of Design Patterns
Last Updated :
30 Oct, 2023
A Pattern, in general, refers to the particular layout which helps to perform certain tasks with ease. Technically, patterns can be considered as devices that help the program in sharing the knowledge of their design.
The term design pattern is used in object-oriented terminology to perform the tasks such as defining the objects, classes, interfaces hierarchy and factoring them into classes with relationships. Once all these steps are considered as a pattern they can reuse them by applying them to several common problems.
A design pattern can be considered as a reusable solution for the commonly occurring problems in software design. A Design pattern is not a finished design, rather it is a template to solve the problem in many different solutions.
The most influential work on design patterns was done by Gamma, Helm, Jonson, and Vlissides are commonly known as Group of Four (GOF). The GoF design pattern can be described as communication among classes and objects which are customized for solving a design problem in a specific context.
Essential Element of Design Pattern:
There are four essential elements of a design pattern. They are as follows:
- Pattern Name: It is a unique name that describes a design problem. Pattern name being concise and meaningful, Improves communication, among developers and helps to design patterns at higher levels of abstraction.
- Problem: It states the problem and its context such as how to represent the algorithm as objects (It ensure when the pattern is applicable and what condition should be met before the pattern is used.
- Solution: It provides a Description of elements that make the design pattern such as their responsibility, relationship, and collaboration). Pattern solutions cant describe a particular implementation because patterns are like templates that are applicable to several similar situations. The solution gives a generic arrangement of classes and objects to solve a problem.
- Consequences: As the name implies these highlight the result, pros and cons of applying the patterns, etc,(It Describes the impacts on the system's portability, extensibility. They determine the costs and evaluate design alternatives of pattern, language, and implementation issues.
The Catalog of Design Patterns:
The Design Patterns are organized into a form of a catalog. These Design Patterns collectively assist in software engineering by finding objects, specifying objects implementations, objects interfaces, determining objects granularity, implementing reuse mechanisms, etc. The Intents specify what the design pattern does. Some of the patterns with their names and intents are as follows,
- Abstract Factory: It Indicates what factory is to be instantiated, provides an interface to create families of objects(related / dependent) without any specification of their concrete classes.
- Adaptor: Id Adapt or converts an interface of a class into another one according to the client expectation and hence, overcomes the problem of incompatible interfaces thereby enabling the classes to work together.
- Bridge: It Separates abstraction from its implementation to make them independent.
- Builder: It Separates the complex objects constructions from their representation in order to create different representations with the same construction process.
- Chain Of Responsibility: It Enables the handling of command objects by passing them to other objects by using the logic present in the processing of objects. In other words, Its decouples sender and receiver by formatting a chain of receiving objects to pass the request until the request is handled by an object.
- Command: It encapsulates the action and its parameters and hence, enables to parameterize the different requests of the clients such as long or queue requests. It also assists undoable operations.
- Composite: It represents the objects in a tree structure where each object represents the same interface. This enables clients to treat individual objects and their compositions uniformly.
- Decorator: It Adds additional functionality to a class at runtime. This Enables flexibility to subclass for adding functionality.
- Facade: It creates a simplified/unified interface of existing interfaces in the subsystems so as to handle common tasks easily.
- Factory Method: It Focuses on objects creation of specific implementation. lets the subclass decide as to which class to be instantiated.
- Flyweight: It Performs sharing of common objects properties by a large number of objects to save space.
- Interpreter: It Deals with the implementation of a specified computer language that solves specific problems. It interprets sentences in language by representing the grammar of language along with an interpreter.
- Iterator: It Enables sequential aggregate objects elements by hiding their underlying representations.
- Mediator: It provides a unified interface to the set of interfaces in a subsystem. It provides loose coupling which enables objects to refer to each explicitly and also varies objects interaction independently.
- Momento: It supports the rollback mechanism by enabling the objects, to restore to their previous state without violation of encapsulation.
- Observer: Whenever an object changes its state, it raises an event that notifies other objects and updates them automatically. This defines a one-to-many dependency between the objects.
- Prototype: Here Prototypical instance determines the type of objects to be created. Further new objects are created by cloning this prototype.
- proxy: It provides an illusion by applying placeholder to other objects in order to have control over it.
- Singleton: It Provides restrictions on instantiating a class to a single object and also makes it globally accessible.
- State: It Permits an alteration in the object's behavior with alteration in its state .i.e allows objects type to change at runtime.
- Visitors: It Describes the skeleton of a program, enables subclasses to define some steps of the algorithm, and also to redefine certain steps without affecting the structure of the algorithm.
- Strategy: It defines the Family of algorithms and their selection based upon the clients.
Uses of Design Patterns in Software Engineering:
A design pattern in the context of software engineering is a template or reusable solution to common problems occurring in software design. This is usually represented with the classes and objects, interfaces, etc. The one application of a design pattern is "Reusability of Solutions", By using the proven solution, users can solve software development issues that enable the development of highly cohesive modules with coupling.
Need of Design pattern:
- Enables efficient communication between designers.
- Solves an issue just by referring to pattern name.
- Improves code readability for coders.
- Reduce the time to find the solution by reusing tested and proven development paradigms.
- Reduce the time for coders.
- Introduces additional levels of indirection to achieve flexibility.
- Reduce the time for understanding the design.
- Avoid those alternatives which avoid reusability thereby reducing variations.
- Improves design understandability and documentation.
- Helps to understand the basics of object-oriented design more easily and quickly.
Similar Reads
Software Design Patterns Tutorial Software design patterns are important tools developers, providing proven solutions to common problems encountered during software development. This article will act as tutorial to help you understand the concept of design patterns. Developers can create more robust, maintainable, and scalable softw
9 min read
Complete Guide to Design Patterns Design patterns help in addressing the recurring issues in software design and provide a shared vocabulary for developers to communicate and collaborate effectively. They have been documented and refined over time by experienced developers and software architects. Important Topics for Guide to Desig
11 min read
Types of Software Design Patterns Designing object-oriented software is hard, and designing reusable object-oriented software is even harder. Christopher Alexander says, "Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way th
9 min read
1. Creational Design Patterns
Creational Design Patterns Creational Design Patterns focus on the process of object creation or problems related to object creation. They help in making a system independent of how its objects are created, composed, and represented. Creational patterns give a lot of flexibility in what gets created, who creates it, and how i
4 min read
Types of Creational Patterns
2. Structural Design Patterns
Structural Design Patterns Structural Design Patterns are solutions in software design that focus on how classes and objects are organized to form larger, functional structures. These patterns help developers simplify relationships between objects, making code more efficient, flexible, and easy to maintain. By using structura
7 min read
Types of Structural Patterns
Adapter Design PatternOne structural design pattern that enables the usage of an existing class's interface as an additional interface is the adapter design pattern. To make two incompatible interfaces function together, it serves as a bridge. This pattern involves a single class, the adapter, responsible for joining fun
8 min read
Bridge Design PatternThe Bridge design pattern allows you to separate the abstraction from the implementation. It is a structural design pattern. There are 2 parts in Bridge design pattern : AbstractionImplementationThis is a design mechanism that encapsulates an implementation class inside of an interface class. The br
4 min read
Composite Method | Software Design PatternComposite Pattern is a structural design pattern that allows you to compose objects into tree structures to represent part-whole hierarchies. The main idea behind the Composite Pattern is to build a tree structure of objects, where individual objects and composite objects share a common interface. T
9 min read
Decorator Design PatternThe Decorator Design Pattern is a structural design pattern that allows behavior to be added to individual objects dynamically, without affecting the behavior of other objects from the same class. It involves creating a set of decorator classes that are used to wrap concrete components.Important Top
9 min read
Facade Method Design PatternFacade Method Design Pattern is a part of the Gang of Four design patterns and it is categorized under Structural design patterns. Before we go into the details, visualize a structure. The house is the facade, it is visible to the outside world, but beneath it is a working system of pipes, cables, a
8 min read
Flyweight Design PatternThe Flyweight design pattern is a structural pattern that optimizes memory usage by sharing a common state among multiple objects. It aims to reduce the number of objects created and to decrease memory footprint, which is particularly useful when dealing with a large number of similar objects.Flywei
10 min read
Proxy Design PatternThe Proxy Design Pattern a structural design pattern is a way to use a placeholder object to control access to another object. Instead of interacting directly with the main object, the client talks to the proxy, which then manages the interaction. This is useful for things like controlling access, d
9 min read
3. Behvioural Design Patterns