This repository contains Java examples for creational, structural, and behavioral design patterns. Each pattern folder includes a short explanation and a Mermaid diagram showing the main participants or flow.
See PATTERN_REVIEW.md for follow-up notes about examples that could better match the intent of their design pattern.
| Category | Pattern | Doc |
|---|---|---|
| Creational | Abstract Factory | abstract-factory.md |
| Creational | Builder | builder.md |
| Creational | Factory Method | factory-method.md |
| Creational | Prototype | prototype.md |
| Creational | Simple Factory Method | simple-factory-method.md |
| Creational | Singleton | singleton.md |
| Structural | Adapter | adapter.md |
| Structural | Bridge | bridge.md |
| Structural | Composite | composite.md |
| Structural | Decorator | decorator.md |
| Structural | Facade | facade.md |
| Structural | Flyweight | flyweight.md |
| Structural | Proxy | proxy.md |
| Behavioral | Chain of Responsibility | chain-of-responsibility.md |
| Behavioral | Command | command.md |
| Behavioral | Interpreter | interpreter.md |
| Behavioral | Iterator | iterator.md |
| Behavioral | Mediator | mediator.md |
| Behavioral | Memento | memento.md |
| Behavioral | Observer | observer.md |
| Behavioral | State | state.md |
| Behavioral | Strategy | strategy.md |
| Behavioral | Template Method | template-method.md |
| Behavioral | Visitor | visitor.md |
flowchart TB
subgraph Creational
direction TB
C1[Abstract Factory]
C2[Builder]
C3[Factory Method]
C4[Prototype]
C5[Simple Factory Method]
C6[Singleton]
C1 ~~~ C2 ~~~ C3 ~~~ C4 ~~~ C5 ~~~ C6
end
subgraph Structural
direction TB
S1[Adapter]
S2[Bridge]
S3[Composite]
S4[Decorator]
S5[Facade]
S6[Flyweight]
S7[Proxy]
S1 ~~~ S2 ~~~ S3 ~~~ S4 ~~~ S5 ~~~ S6 ~~~ S7
end
subgraph Behavioral
direction TB
B1[Chain of Responsibility]
B2[Command]
B3[Interpreter]
B4[Iterator]
B5[Mediator]
B6[Memento]
B7[Observer]
B8[State]
B9[Strategy]
B10[Template Method]
B11[Visitor]
B1 ~~~ B2 ~~~ B3 ~~~ B4 ~~~ B5 ~~~ B6 ~~~ B7 ~~~ B8 ~~~ B9 ~~~ B10 ~~~ B11
end