Skip to content

This repository provides implementations of key Software Design Patterns in Java, categorized into Creational, Structural, and Behavioral patterns. Each pattern is implemented as an individual, self-contained project with minimal code and maximum clarity, making it perfect for learning and quick reference.

Notifications You must be signed in to change notification settings

Mr-G-D/Project-Design-Pattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎯 Java Design Patterns Showcase

This repository demonstrates key Software Design Patterns in Java, grouped by category:

  • Creational
  • Structural
  • Behavioral

Each pattern is implemented as an individual, self-contained project with minimal code and maximum clarity β€” designed for both learning and reference.


πŸ“ Project Structure

design-patterns-java/
β”œβ”€β”€ creational/
β”‚   β”œβ”€β”€ singleton/
β”‚   β”‚   └── LoggerModule.java
β”‚   β”œβ”€β”€ builder/
β”‚   β”‚   └── UserModule.java
β”‚   └── abstract-factory/
β”‚       └── UIGenerator.java
β”œβ”€β”€ structural/
β”‚   β”œβ”€β”€ facade/
β”‚   β”‚   └── HomeTheaterSystem.java
β”‚   └── adapter/
β”‚       └── MusicPlayer.java
└── behavioral/
    β”œβ”€β”€ strategy/
    β”‚   └── NavigatorModule.java
    └── observer/
        └── WeatherApplication.java

🧱 Creational Patterns

πŸ”Ή Singleton

Ensures a class has only one instance and provides a global point of access to it.

βœ… Key Concepts:

  • Private constructor
  • Static instance
  • Thread-safe (with double-checked locking)

πŸ”Ή Builder

Builds complex objects step-by-step without using telescoping constructors.

βœ… Key Concepts:

  • Immutable object creation
  • Chainable setter methods
  • build() method

πŸ”Ή Abstract Factory

Creates families of related objects without specifying concrete classes.

βœ… Key Concepts:

  • Factory of factories
  • Consistency across product families (e.g., Mac UI vs Windows UI)

🧩 Structural Patterns

πŸ”Ή Facade

Provides a simplified interface to a complex subsystem.

βœ… Key Concepts:

  • Hides complexity
  • Single entry point
  • Ideal for APIs and libraries

πŸ”Ή Adapter

Allows incompatible interfaces to work together.

βœ… Key Concepts:

  • Converts one interface to another
  • Useful for integrating legacy code

πŸ” Behavioral Patterns

πŸ”Ή Strategy

Defines a family of algorithms, encapsulates each one, and makes them interchangeable at runtime.

βœ… Key Concepts:

  • Interface-based design
  • Replace logic at runtime
  • Promotes flexibility

πŸ”Ή Observer

Defines a one-to-many dependency between objects β€” when one changes, all dependents are notified.

βœ… Key Concepts:

  • Publisher-subscriber model
  • Real-time notifications
  • Loosely coupled components

πŸš€ How to Run

Each pattern resides in its own folder with a dedicated Main.java. You can:

  1. Open the folder in your IDE (e.g., IntelliJ, Eclipse)
  2. Run Main.java
  3. Observe the output in the console

πŸ›  Technologies Used

  • Java 17 (or compatible version)
  • No external dependencies
  • IDE-agnostic folder structure

πŸ“š Resources for Further Learning


🀝 Contributing

Feel free to fork, modify, and submit pull requests. If you have ideas for additional patterns or examples, contributions are welcome!


πŸ“„ License

This project is licensed under the MIT License.


πŸ“Œ Author

Dinesh Kumar Gopinathan


⭐ If this helped you understand design patterns better, consider giving it a star!

About

This repository provides implementations of key Software Design Patterns in Java, categorized into Creational, Structural, and Behavioral patterns. Each pattern is implemented as an individual, self-contained project with minimal code and maximum clarity, making it perfect for learning and quick reference.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages