My notes from – “Design Patterns: Elements of Reusable Object-Oriented Software” Book

Santhosh Adiga U
4 min readApr 4, 2023

--

Design patterns are a set of reusable solutions to common software design problems. In “Design Patterns: Elements of Reusable Object-Oriented Software,” a book written by the “Gang of Four,” authors Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides introduced 23 design patterns, which were categorized into three groups: Creational, Structural, and Behavioral. Here are some of the key points from the book:

Creational Patterns

Creational patterns deal with object creation mechanisms, trying to create objects in a way that is suitable for the situation. The patterns under this category are the Singleton, Factory Method, Abstract Factory, Builder, and Prototype. Singleton ensures that a class has only one instance and provides a global point of access to it. The Factory Method provides an interface for creating objects in a superclass but allows the subclasses to alter the type of objects that will be created. The Abstract Factory pattern provides an interface for creating a family of related objects without specifying their concrete classes. The Builder pattern separates the construction of a complex object from its representation, allowing the same construction process to create different representations. The Prototype pattern specifies the kinds of objects to create using a prototypical instance, and creates new objects by cloning this prototype.

Structural Patterns

Structural patterns are concerned with object composition, forming larger structures from individual objects. The patterns under this category are Adapter, Bridge, Composite, Decorator, Facade, Flyweight, and Proxy. The Adapter pattern converts the interface of a class into another interface that clients expect. The Bridge pattern decouples an abstraction from its implementation so that the two can vary independently. The Composite pattern composes objects into tree structures to represent part-whole hierarchies, where individual objects and compositions of objects are treated uniformly. The Decorator pattern attaches additional responsibilities to an object dynamically, providing a flexible alternative to subclassing. The Facade pattern provides a unified interface to a set of interfaces in a subsystem, making the subsystem easier to use. The Flyweight pattern uses sharing to support large numbers of fine-grained objects efficiently. The Proxy pattern provides a surrogate or placeholder for another object to control access to it.

Behavioral Patterns

Behavioral patterns are concerned with communication between objects, providing solutions for the interaction between objects and how they operate together. The patterns under this category are Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, and Visitor. The Chain of Responsibility pattern passes a request along a chain of objects until one of them handles the request. The Command pattern encapsulates a request as an object, allowing the request to be parameterized with different requests, queued or logged, and undoable. The Interpreter pattern defines a grammar for a language and interprets sentences in that language. The Iterator pattern provides a way to access the elements of an object without exposing its underlying representation. The Mediator pattern defines an object that encapsulates how a set of objects interact. The Memento pattern captures and externalizes an object’s internal state, so that it can be restored later. The Observer pattern defines a one-to-many dependency between objects, so that when one object changes state, all its dependents are notified and updated automatically. The State pattern allows an object to alter its behavior when its internal state changes. The Strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. The Template Method pattern defines the skeleton of an algorithm in a method, deferring some steps to subclasses. The Visitor pattern defines a new operation to a class hierarchy without changing the classes themselves.

In conclusion, “Design Patterns: Elements of Reusable Object-Oriented Software” is a classic book that has had a significant impact on software engineering. It introduced the concept of design patterns and provided a common vocabulary and framework for developers to discuss and solve common design problems. The book is essential reading for any software developer, and the patterns it describes have been used extensively in real-world software projects.

The patterns described in the book are not prescriptive, but rather provide guidelines for solving common design problems. Each pattern can be adapted to suit the needs of a particular project, and the patterns can be combined and used in different ways to create new solutions. The authors emphasize that the patterns should not be used blindly, but rather should be applied with care and consideration for the specific problem being solved.

Design patterns provide a way to design software that is flexible, reusable, and maintainable. By following the patterns described in “Design Patterns: Elements of Reusable Object-Oriented Software,” developers can create software that is easy to understand and modify, reducing the risk of bugs and making it easier to add new features. The book has become a classic in the field of software engineering, and its influence can still be felt today in modern software development practices.

The key points from “Design Patterns: Elements of Reusable Object-Oriented Software” are the 23 patterns that the book describes, which are organized into three categories: Creational, Structural, and Behavioral. These patterns provide guidelines for solving common design problems and are used extensively in real-world software projects. By following these patterns, developers can create software that is flexible, reusable, and maintainable. The book is essential reading for any software developer and has had a significant impact on the field of software engineering.

--

--

Santhosh Adiga U
Santhosh Adiga U

Written by Santhosh Adiga U

Founder of Anakramy Inc., dedicated to creating innovative AI-driven cybersecurity solutions.

No responses yet