This repository provides a comprehensive guide to various design patterns implemented in Java. Each pattern is presented with clear explanations, practical examples, and usage scenarios, along with quizzes to test your understanding.
- Decorator Design Pattern
- Composite Design Pattern
- Bridge Design Pattern
- Builder Design Pattern
- Chain of Responsibility Design Pattern
- Flyweight Design Pattern
- Interpreter Design Pattern
- Mediator Design Pattern
- Memento Design Pattern
- Prototype Design Pattern
- Visitor Design Pattern
- Compound Patterns
- Anti-Patterns
Each design pattern listed above has its own dedicated folder within this repository. Inside each pattern's folder, you will typically find:
about/
: Provide Introduction about this pattern its charateristics usage and key components.src/
: Contains the Java source code demonstrating the pattern's implementation with quiz explain.quizzes/
: Includes questions and exercises related to the pattern to reinforce learning.
-
Creational Patterns These design patterns provide a way to create objects while hiding the creation logic, rather than instantiating objects directly using new operator. This gives program more flexibility in deciding which objects need to be created for a given use case.
-
Structural Patterns These design patterns concern class and object composition. Concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities.
-
Behavioral Patterns These design patterns are specifically concerned with communication between objects.
- Description: Discusses how to dynamically add new functionalities to an object without altering its structure.
- Description: Explains how to compose objects into tree structures to represent part-whole hierarchies.
- Description: Covers how to decouple an abstraction from its implementation so that the two can vary independently.
- Description: Details how to construct a complex object step by step, allowing for different representations using
- Description: Explores how to pass requests along a chain of handlers, decoupling the sender from the receiver.
- Description: Explains how to minimize memory usage or computation expenses by sharing as much data as possible
- Description: Covers how to define a grammatical representation for a language and provide an interpreter to deal
- Description: Discusses how to reduce coupling between objects by introducing a mediator object that encapsulates
- Description: Explains how to capture and externalize an object's internal state so that the object can be restored to this state later.
- Description: Covers how to create new objects by copying an existing object, known as the prototype.
- Description: Discusses how to separate an algorithm from the object structure on which it operates.
- Description: Explores how to combine multiple design patterns to solve more complex problems, often demonstrating
- Description: Identifies common pitfalls and bad practices in software design, explaining why they are problematic and how to avoid them.
Contributions are welcome! If you have additional examples, improved explanations, or new quizzes, feel free to open a pull request.