The primary goal of this repository is to provide a comprehensive collection of Design Patterns implemented in Java. It serves as an educational resource for developers to understand the structure, implementation, and practical application of various architectural patterns.
This project is divided into three main perspectives:
- Structures: Pure implementation of patterns, focusing on the core structure and relationships between classes.
- Examples: Real-life-like examples showing how patterns can be applied to solve specific problems.
- Without Patterns: Code examples demonstrating how a solution might look like before applying a design pattern, highlighting the problems that patterns are meant to solve.
The repository is structured as a Maven multi-module project:
Contains the "academic" implementation of the patterns. This is the place to look if you want to understand the UML diagram of a pattern translated into code.
- Creational Patterns (e.g., Singleton, Factory Method, Builder)
- Structural Patterns (e.g., Adapter, Bridge, Composite)
- Behavioral Patterns (e.g., Strategy, Observer, Command)
Showcases the patterns in action. Each example provides a context where a specific pattern brings value, making it easier to grasp the "why" behind the "how".
A collection of "bad code" examples. These are implementations that suffer from issues like high coupling, low cohesion, or poor extensibility—precisely the problems that design patterns help to mitigate. Use these as a starting point for refactoring exercises.
- Explore by Pattern: Navigate through the packages in
structuresto see the basic implementation. - Understand the Value: Compare the code in
withoutpatternswith its counterparts inexamplesto see the transformation and benefits. - Practice: Try to refactor code from
withoutpatternsusing the knowledge fromstructures.
- Java 17
- Maven
- JUnit 5 & AssertJ for testing
- Mockito for mocking in tests
- Guava
To build the project and run tests:
mvn clean installCreated and maintained by Sebastian Malaca, an Architect, Developer, and Trainer passionate about software quality and evolutionary design.
If you are looking for more advanced architectural concepts, check out Training Center Microservices.