Official repository by Corbat.tech, inspired by the book Design Patterns: Elements of Reusable Object-Oriented Software (Gang of Four).
This repository provides clear explanations and code examples of the 23 classic design patterns, implemented in Java 21, following clean code principles.
π Goal: To serve as a modern, practical guide for learning and applying each pattern, with concise comments only where truly necessary.
| Pattern | Short Description |
|---|---|
| Abstract Factory | Provides an interface for creating families of related objects without specifying their concrete classes. |
| Builder | Separates the construction of a complex object from its representation so that the same construction process can create different representations. |
| Factory Method | Defines an interface for creating an object but lets subclasses decide which class to instantiate. |
| Prototype | Specifies the kinds of objects to create using a prototypical instance and creates new objects by copying this prototype. |
| Singleton | Ensures a class has only one instance and provides a global point of access to it. |
| Pattern | Short Description |
|---|---|
| Adapter | Allows incompatible interfaces to work together through an adapter. |
| Bridge | Separates an abstraction from its implementation so that the two can vary independently. |
| Composite | Composes objects into tree structures to represent part-whole hierarchies. |
| Decorator | Adds additional responsibilities to an object dynamically. |
| Facade | Provides a unified interface to a set of interfaces in a subsystem. |
| Flyweight | Uses sharing to support large numbers of fine-grained objects efficiently. |
| Proxy | Provides a surrogate or placeholder for another object to control access to it. |
| Pattern | Short Description |
|---|---|
| Chain of Responsibility | Passes a request along a chain of handlers. |
| Command | Encapsulates a request as an object, thereby allowing for parameterization of clients with queues, requests, and operations. |
| Interpreter | Given a language, defines a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language. |
| Iterator | Provides a way to access elements of an aggregate object sequentially without exposing its underlying representation. |
| Mediator | Defines an object that encapsulates how a set of objects interact. |
| Memento | Without violating encapsulation, captures and externalizes an object's internal state so that it can be restored later. |
| Observer | Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified. |
| State | Allows an object to alter its behavior when its internal state changes. |
| Strategy | Defines a family of algorithms, encapsulates each one, and makes them interchangeable. |
| Template Method | Defines the skeleton of an algorithm in a method, deferring some steps to subclasses. |
| Visitor | Represents an operation to be performed on the elements of an object structure. |
- Navigate to the folders by pattern category.
- Read the detailed README in each pattern folder.
- Explore the code examples written in Java 21.
- Clone the repository to run the examples locally if needed.
π¬ Contact: For any questions or suggestions, visit www.corbat.tech or open an issue in this repository.