← All open source projects

Java Design Patterns

iluwatar/java-design-patterns

Java Design Patterns is a large collection of design patterns implemented in Java, with explanations, examples, and links to architectural problems.

Forks 27,365
Author iluwatar
Language Java
License NOASSERTION
Synced 2026-06-09

What it is

Java Design Patterns is a learning repository about design patterns. It shows not only names such as Factory, Strategy, or Observer, but Java implementations with context: when an approach helps and where it may be too much.

The project is useful because patterns are often learned too abstractly. In real code, developers need to see class roles, dependencies, extensibility, and the cost of extra structure.

What is inside and how people use it

Inside are many patterns, documentation, tests, examples, and a website. The material is grouped by object creation, composition, behavior, concurrency, integration, and architectural styles.

Strategy idea

This pseudo-Java fragment shows the core of Strategy: the algorithm is swapped through a shared interface.

Language: Plain text
interface PaymentStrategy {
  void pay(int amount);
}

class Checkout {
  void complete(PaymentStrategy strategy) {
    strategy.pay(100);
  }
}

A typical use case is recognizing a problem in code and checking how a similar task is expressed through a known pattern. That does not mean the pattern should be inserted automatically.

Strengths and limitations

The strength is broad coverage tied to code. The repository works well as a reference and learning ground, especially for Java teams.

The limitation is overengineering risk. A pattern is useful when it reduces complexity, not when it adds classes for a nice name.