Catalog of Design Patterns
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.
Please Login to comment...