A clean, runnable collection of Gang of Four (GoF) design patterns implemented in Java, organized by category (Creational / Structural / Behavioural) with simple demo runners.
- Observer
- Iterator
- Strategy
- Chain of Responsibility
- State
- Factory
- Abstract Factory
- Builder
- Prototype
- Singleton
- Composite
- Adapter
- Proxy
- Flyweight
- Facade
- Bridge
- Decorator
You have two ways to run this project:
Use the release/ folder — it contains a ready-to-run JAR so you don’t need NetBeans or compiling.
- Open
release/ - Open the
jar/folder (this containsDesign_Patterns.jar) - Run it:
- Windows: double-click
run.bat - macOS: double-click
run.command(may show a one-time security prompt) - Linux: double-click
Design Patterns.desktop(some desktops may ask “Allow Launching” once)
If you prefer command line, go inside release/jar/ and run:
java -jar "Design_Patterns.jar"Requirements: Java 21.
Use this if you want to inspect/edit the code.
Run the Menu App (recommended inside NetBeans)
- Open
Demo/DemoApp.java - Right-click → Run File
- Use the menu to pick the category + pattern demo
Run a single pattern demo
- Expand a category package (e.g.,
Behavioral/Strategy) - Open the
*Democlass - Right-click → Run File
All demos extend
Demoand implementRunnable(run()), so every pattern runs in a consistent way.
Demo.javaprovides a common structure for consistent execution- Patterns are separated by category and kept in their own packages
- Naming is kept straightforward (e.g.,
Context,State,Strategy,Factory, etc.)