Java Design Patterns
One of the most starred Java repositories on GitHub: open source implementations of the Gang of Four patterns and many more, each with an explanation, a Java example and runnable code. Read it after you understand a pattern, to see a complete working version in Java.
94.7k
GitHub · Sept 2026
27.4k
GitHub · Sept 2026
MIT
GitHub README · Sept 2026
GitHub repo
Other
iluwatar and contributors
Use as a reference, one pattern at a time
Intermediate
Free
What it is
Java Design Patterns is an open source project on GitHub that implements software design patterns in Java. Each pattern lives in its own folder with an explanation, a diagram and a small runnable program, and the same content is published as a browsable website at java-design-patterns.com. The patterns are organised by category, creational, structural and behavioural, plus architectural approaches, and can be filtered by tags such as Gang of Four. The project is licensed under the MIT licence.
It is not only the 23 Gang of Four patterns. The repository also covers many later patterns, including architectural and concurrency ones, which makes it a good place to look up a name you meet in a code base.
How to use it well
Do not start here. The explanations are short and assume you already know why a pattern exists. A better order is:
- Learn the problem and the idea of a pattern from a course or a guide.
- Write your own version from memory.
- Open the pattern's folder here and compare: what did they do differently, and why?
- Run the example, then change something and see what breaks.
Comparing your attempt with a complete, reviewed implementation is where most of the learning happens.
What you will find in each pattern
Pattern pages follow a common structure. The Strategy page, for example, covers the intent, a detailed explanation with real-world examples, a programmatic example in Java, when to use it, real-world applications, benefits and trade-offs, related patterns and references. The real-world applications sections are especially valuable: they show you the pattern inside libraries and frameworks you already use.
Is it up to date?
The repository is actively maintained, with commits in September 2026. Some older examples use Java styles that predate records and sealed types, so when you compare, ask whether modern Java would let you write it more simply.
Prerequisites
You should be comfortable with Java classes, interfaces, generics and lambdas, and able to build a Maven project from the command line or your IDE.
Common questions
Is it free? Yes, the code and the website are free. The README also mentions an e-book compiled from the project.
Can I contribute? Yes. The README points to a developer wiki with contribution guidelines, and improving an explanation or adding a test is a good first open source contribution.
Best for: Java learners who already know the idea of a pattern and want a complete, tested reference implementation.
Ready to start?
Opens on iluwatar and contributors in a new tab.
Stuck on something specific?
Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.
Follow along
New writing, resources and project ideas land here first.