Daily Dotnet - Your bite-sized update of .NET, C#, and Azure

Ankit Kashyap

Published On

2023-01-28

Daily Archives
  • design-patterns

Going to read the GOF book?

The Gang of Four book, also known as "Design Patterns: Elements of Reusable Object-Oriented Software," is a book written by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. It was first published in 1994 and is considered a classic in the field of software engineering.
The book presents 23 design patterns that are commonly used in object-oriented programming. These patterns are organized into three categories: creational, structural, and behavioral patterns. The book has been widely influential in the software development community and is considered a must-read for software engineers and architects. It's considered a classic in software development, and the patterns described in the book are still widely used today in many modern programming languages and frameworks.
 
Creational Patterns (5): These patterns focus on creating objects and classes in a flexible and efficient way.
  1. Abstract Factory: The Abstract Factory pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes.
  1. Builder: The Builder pattern separates the construction of a complex object from its representation so that the same construction process can create different representations.
  1. Factory Method: The Factory Method pattern defines an interface for creating an object but let subclasses decide which class to instantiate.
  1. Prototype: The Prototype pattern creates new objects by copying existing objects, which serves as a prototype.
  1. Singleton: The Singleton pattern ensures a class has only one instance while providing a global access point to this instance.
The creational patterns are used to create objects and classes in a flexible and efficient way, and they are often used to solve problems related to creating and managing objects and classes in a program.
 
Structural Patterns (7): These patterns focus on how objects and classes can be composed to form larger structures.
  1. Adapter: The Adapter pattern allows objects with incompatible interfaces to work together by wrapping an adapter object around one of the objects.
  1. Bridge: The Bridge pattern separates an object's interface from its implementation, allowing the two to vary independently.
  1. Composite: The Composite pattern allows you to compose objects into tree structures to represent part-whole hierarchies.
  1. Decorator: The Decorator pattern allows behavior to be added to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class.
  1. Facade: The Facade pattern provides a simplified interface to a complex system of classes.
  1. Flyweight: The Flyweight pattern uses sharing to efficiently support large numbers of fine-grained objects.
  1. Proxy: The Proxy pattern provides a surrogate or placeholder object for another object and controls access to this other object.
Structural patterns are used to solve problems related to the composition of objects and classes in a program. They are often used to make the code more flexible and maintainable.
 
Behavioral Patterns (11):
  1. Chain of Responsibility: The Chain of Responsibility pattern allows multiple objects to handle a request without specifying the receiver explicitly.
  1. Command: The Command pattern encapsulates a request as an object, thereby letting you parametrize other objects with different requests.
  1. Interpreter: The Interpreter pattern provides a way to evaluate a language or notation.
  1. Iterator: The Iterator pattern allows you to traverse a container and access the container's elements without exposing its internal structure.
  1. Mediator: The Mediator pattern allows objects to communicate without knowing each other's identities.
  1. Memento: The Memento pattern allows you to capture an object's internal state and restore it later.
  1. Observer: The Observer pattern allows objects to be notified of changes in other objects.
  1. State: The State pattern allows an object to change its behavior when its internal state changes.
  1. Strategy: The Strategy pattern allows you to define a family of algorithms, encapsulate each one as an object, and make them interchangeable.
  1. Template Method: The Template Method pattern defines the skeleton of an algorithm in a method, allowing subclasses to provide the implementation details.
  1. Visitor: The Visitor pattern separates an algorithm from an object structure by moving the hierarchy of methods into one object.
Behavioral patterns are used to solve problems related to managing and coordinating objects and classes in a program. They are often used to make the code more flexible and maintainable.
 
Top patterns?
  1. Singleton: Ensures a class has only one instance, while providing a global access point to this instance.
  1. Factory Method: Defines an interface for creating an object, but let subclasses decide which class to instantiate.
  1. Observer: Allows objects to be notified of changes in other objects.
  1. Decorator: Allows behavior to be added to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class.
  1. Builder: Separates the construction of a complex object from its representation so that the same construction process can create different representations.
  1. Adapter: Allows objects with incompatible interfaces to work together by wrapping an adapter object around one of the objects.
  1. Template Method: Defines the skeleton of an algorithm in a method, allowing subclasses to provide the implementation details.
  1. Prototype: Creates new objects by copying existing objects, which serves as a prototype.
  1. Command: Encapsulates a request as an object, thereby letting you parametrize other objects with different requests.
  1. Bridge: Separates an object's interface from its implementation, allowing the two to vary independently.
 
Supporting materials
 
In summary, the Gang of Four book is a seminal work on software design patterns, providing a catalog of 23 commonly used patterns in object-oriented programming. It is widely considered a classic in the field of software engineering and continues to be influential in the software development community.
 

Not a daily person? Subscribe the weekly newsletter

Made with 💖 in Beautiful British Columbia 🍁