Which design pattern isn’t a GoF design pattern?
Design patterns are essential tools for software developers, allowing them to write code that is efficient, maintainable, and reusable. The most well-known collection of design patterns was published in the book Design Patterns: Elements of Reusable Object-Oriented Software by the Gang of Four (GoF). However, there are many other design patterns out there that aren’t part of the GoF collection. In this blog post, we’ll take a look at which pattern isn’t a GoF design pattern.
What are the GoF design patterns?
The GoF (Gang of Four) design patterns are a set of 23 object-oriented software design patterns that were first described by the book Design Patterns: Elements of Reusable Object-Oriented Software. These patterns provide a common vocabulary for describing common solutions to problems faced in software development. The GoF patterns are divided into three categories: creational, structural, and behavioral.
Creational design patterns involve instantiating objects in specific ways, such as creating an object through cloning or via factory methods. Some of the more commonly used creational design patterns include the Singleton, Abstract Factory, Builder, Prototype, and Factory Method patterns.
Structural design patterns describe how classes and objects can be composed to form larger structures and systems. Structural patterns are focused on the way objects are connected to form larger structures. Commonly used structural design patterns include Adapter, Bridge, Composite, Decorator, Facade, Flyweight, and Proxy patterns.
Behavioral design patterns describe how classes and objects interact with each other to form larger structures and systems. Behavioral patterns are focused on how objects interact with each other to create complex behaviors. Commonly used behavioral design patterns include the Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, and Visitor patterns.
The GoF design patterns provide developers with an invaluable tool for solving commonly encountered problems in software development. By understanding and using these design patterns, developers can create code that is better organized and easier to maintain.
What is the difference between a creational, structural, and behavioral pattern?
Creational patterns are concerned with the process of creating objects and deal with object creation mechanisms. They provide ways to create objects while hiding the creation logic, rather than instantiating objects directly. Examples of creational patterns include Abstract Factory, Builder, Factory Method, Prototype, and Singleton.
Structural patterns are focused on how classes and objects can be composed to form larger structures. These patterns use inheritance to compose interfaces and define relationships between objects. Examples of structural patterns include Adapters, Bridges, Composites, Decorators, Facades, and Proxies.
Behavioral patterns are concerned with algorithms and the assignment of responsibilities between objects. These patterns use object composition rather than inheritance. Behavioral patterns describe how objects interact with each other and the strategies for communication between them. Examples of behavioral patterns include Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, and State.