This repository provides examples of design patterns mentioned in GoF Design Patterns book implemented in Java. The examples are categorized into three sections: Creational Patterns, Structural Patterns, and Behavioral Patterns.
- Singleton: Creating only one instance of a class.
- Factory Method: Abstracting the object creation process.
- Abstract Factory: Abstracting the creation of object families.
- Builder: Structuring the creation of complex objects.
- Prototype: Creating new objects by copying from an existing instance.
The Builder pattern examples taken from Effective Java book Item 2 and Java-App1-Jun 2022 course given by Oğuz Karan
- Adapter: Making incompatible interfaces compatible.
- Bridge: Separating the abstraction from its implementation through abstraction.
- Composite: Designing a whole-part relationship.
- Decorator: Dynamically adding new features to an object.
- Facade: Simplifying the usage of a complex subsystem.
- Flyweight: Reducing the number of objects by sharing them.
- Proxy: Controlling access to an object.
- Chain of Responsibility: Reducing the dependency between the requesting client and the object that handles the request.
- Command: Reducing the dependency between the requesting client and the object that executes the request, and abstracting the request expressed at the method level to gain additional capabilities at the object level.
- Iterator: Providing a way for sequential access to multiple objects in collections or containers.
- Mediator: Facilitating communication and coordination among multiple objects.
- Memento: Storing the state of an object for later retrieval without breaking encapsulation.
- Observer: Being aware of changes in the state of an object.
- State: Expressing behaviors that depend on the complex states of an object.
- Strategy: Expressing different ways of doing a task independently of the requesting client and in a way that the strategies are interchangeable.
- Template Method: Expressing the general structure of an algorithm and leaving the specific steps to be filled in.
- Visitor: Enabling performing an operation on multiple objects without changing their interfaces.