Java implementation of Matthew Jones's Daily Design Patterns series.
Design Patterns in C# - blog posts
Design Patterns Quick Reference
- Factory Method
- Abstract Factory
- Facade
- Adapter
- Bridge
- Template Method
- Iterator
- Observer
- Memento
- Prototype
- Singleton
- Flyweight
- Builder
- State
- Strategy
- Proxy
- Decorator
- Chain of Responsibility
- Visitor
- Composite
- Mediator
- Command
All example code was written using Java 17, please make sure you have it installed and configured in your environment.
Many of the examples can be launched simply from your IDE (IntelliJ IDEA for example), but some of them are console applications and must be run from the command line. This was a conscious choice and an ode to my laziness.
All the examples can be run from the command line using the following commands: First run the following command in the root directory to compile the code:
mvn clean install
Then navigate to the directory of the example you want to run and run the following command:
01_factory_method>java -cp target\01_factory_method-1.0-SNAPSHOT.jar entrypoint.Program
Replace 01_factory_method
with the directory of the example you want to run. The entrypoint.Program
is the main class for all the example modules.
After a quick glance you may notice that the code is not exactly the same as the original C# code. I've made some changes to the code to make it more idiomatic to Java. You may notice that in the examples I've not used the typical naming conventions for packages and maven groupIds / artifactIds. This was a conscious choice to keep all the examples as abstract and simple as possible.
You can read about the naming conventions that I didn't follow in the following links:
This project is licensed under the BSD 3-Clause license - see the LICENSE file for details