Let me explain Everything you need to know about DESIGN PATTERNS

by KaliLinuxCode

in ,

No Cheating

The Gang of Four (GoF) design patterns are a set of 23 foundational software design patterns described in the book “Design Patterns: Elements of Reusable Object-Oriented Software” by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. These patterns provide solutions to common problems encountered in software design and are grouped into three main categories: Creational, Structural, and Behavioural.

The three main categories of the Gang of Four (GoF) Design Patterns are Creational, Structural, and Behavioral.

Creational Patterns:  Creational Patterns actually deal with object creation mechanisms, main purpose is to create objects as per requirements. Creational Design Patterns make sure system remains independent for example how its objects are created, composed, and represented.

List of Creational Design Patterns and their Functions

Abstract Factory: Provides an interface for creating families of related or dependent objects without specifying their concrete classes.

Builder: Separates the construction of a complex object from its representation, allowing the same construction process to create different representations.

Factory Method: Defines an interface for creating an object but allows subclasses to alter the type of objects that will be created.

Prototype: Creates new objects by copying an existing object, known as the prototype.

Singleton: Ensures a class has only one instance and provides a global point of access to it.

Structural Patterns: These patterns concern how classes and objects are composed to form larger structures. They help ensure that if one part of a system changes, the entire structure does not need to do so.

List of Structural Design Patterns and their Functions

Adapter: Allows incompatible interfaces to work together by converting the interface of a class into another interface clients expect.

Bridge: Decouples an abstraction from its implementation so that the two can vary independently.

Composite: Composes objects into tree structures to represent part-whole hierarchies, allowing individual objects and compositions to be treated uniformly.

Decorator: Adds additional responsibilities to an object dynamically.

Facade: Provides a simplified interface to a complex subsystem.

Flyweight: Reduces the cost of creating and manipulating a large number of similar objects by sharing common parts of the state.

Proxy: Provides a surrogate or placeholder for another object to control access to it.

Behavioral Patterns: These patterns concern how classes and objects are composed to form larger structures. They help ensure that if one part of a system changes, the entire structure does not need to do so.

List of Behavioral Design Patterns and their Functions

Chain of Responsibility: Passes a request along a chain of handlers, where each handler decides either to process the request or to pass it to the next handler in the chain.

Command: Encapsulates a request as an object, thereby allowing for parameterization of clients with queues, requests, and operations.

Interpreter: Defines a grammatical representation for a language and an interpreter to interpret the sentences of that language.

Iterator: Provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

Mediator: Defines an object that encapsulates how a set of objects interact, promoting loose coupling by keeping objects from referring to each other explicitly.

Memento: Captures and externalizes an object’s internal state so that the object can be restored to this state later.

Observer: Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.

State: Allows an object to alter its behavior when its internal state changes, appearing as if it changed its class.

Strategy: Defines a family of algorithms, encapsulates each one, and makes them interchangeable.

Template Method: Defines the skeleton of an algorithm in an operation, deferring some steps to subclasses.

Visitor: Represents an operation to be performed on the elements of an object structure, allowing new operations to be defined without changing the classes of the elements on which it operates.

WWW.KaliLinuxCode.Com   

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *