This repository contains executable examples to illustrate and demonstrate patterns described in our book Patterns Kompakt - Entwurfsmuster für effektive Softwareentwicklung, Verlag Springer Vieweg, Februar 2024.
Information in German and a quick start project download can be found at the book's website patterns-kompakt.de.
The repository contains Java code and runs as a Maven-build. Until Java 7 the project was entirely independent and just leveraging classes contained in the JDK. Because since then the JDK has been trimmed considerably, the example code base was reshaped into a Maven project with a couple of external dependencies. While this may be an extra hurdle for newbees it increases flexibility a lot and better meets common standards and best practices.
Besides a working git installation for cloning the repository you need:
Once done with the preparation simply run mvn clean install
. This will run tests for all patterns with minimal logging. The first time it may take a while to download the maven artifacts the project depends on.
- Install any IDE (e.g., Eclipse or Visual Studio Code) for easier coding and better overview.
- SonarLint can help preventing bugs, and due to its built-in documentation it gives valuable insights about the programming language. At least I learned a lot by reviewing the reasoning behind the SonarLint rules.
- At the time of writing I am using Linux MINT inside a Virtual Box. This way, you don't need to worry about ruining your local installation with a different JDK, IDE or Maven.
- Markdown is a light-weight way to do necessary documentation along with your code. For editing on Linux I use Ghostwriter, which I found easy to install and pretty intuitive. On MacOS I use MacDown. There are also excellent Markdown plugins available for Visual Studio Code.
- In this project I use a minimalistic template to introduce each scenario and describe a particular pattern. For lean documention of real projects I recommend taking a look at arc42.
I have organized the patterns as separate packages with JUnit test cases to demonstrate each pattern.
Every scenario is documented in a dedicated Markdown file. By intention I have chosen different scenarios than those described in the book, for practical programming reasons on the one hand and on the other hand to give the readers a second view on each pattern. Leveraging test cases allowed me to separate setup and dynamic demonstration aspects from the class structure of a pattern.
By adjusting the log-level (SLF4J+Logback) you can watch a pattern at work. The pattern examples do not depend on each other, so that (besides a few utility classes) you have maximum cohesion and focus inside each pattern's package.
I invite you to experiment with the patterns and to think about the choice that was made. Maybe you will come to the conclusion that a different pattern would have been better for a particular scenario?
Most important: Have fun! 😏
Karl Eilebrecht, January 2024