/daily-design-patterns-java

Java implementation of Matthew Jones's Daily Design Patterns series

Primary LanguageJavaBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

daily-design-patterns-java

Java implementation of Matthew Jones's Daily Design Patterns series.

Based on the following:

Design Patterns in C# - blog posts

Design Patterns in C# - repo

Design Patterns Quick Reference

Descriptions

  1. Factory Method
  2. Abstract Factory
  3. Facade
  4. Adapter
  5. Bridge
  6. Template Method
  7. Iterator
  8. Observer
  9. Memento
  10. Prototype
  11. Singleton
  12. Flyweight
  13. Builder
  14. State
  15. Strategy
  16. Proxy
  17. Decorator
  18. Chain of Responsibility
  19. Visitor
  20. Composite
  21. Mediator
  22. Command

Running the examples

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.

Disclaimer

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:

Maven naming conventions

Java package name conventions

License

This project is licensed under the BSD 3-Clause license - see the LICENSE file for details