A curated repository demonstrating the practical implementation of core Software Design Patterns (Creational, Structural, and Behavioral) in object-oriented programming (OOP). This repository serves as a technical reference for building scalable, decoupled, and highly maintainable software architectures with strict adherence to SOLID principles and Clean Code standards.
Design patterns are reusable solutions to common software design problems. Rather than focusing on syntax, this repository showcases the structural blueprints required to avoid spaghetti code and enforce strict object-oriented design paradigms.
- Language: Java (Strongly typed OOP environment)
- Principles Applied: SOLID (SRP, OCP, LSP, ISP, DIP), High Cohesion, Loose Coupling.
- Reference Material: "Design Patterns: Elements of Reusable Object-Oriented Software" by the Gang of Four (GoF).
Focuses on handling object creation mechanisms in a optimized way, decoupling the system from how its objects are created and composed.
- Singleton: Ensuring a class has only one instance while providing a global access point to it.
- Factory Method: Providing an interface for creating objects in a superclass, but allowing subclasses to alter the type of objects that will be created.
- Abstract Factory: Producing families of related objects without specifying their concrete classes.
- Builder: Constructing complex objects step-by-step, allowing the separation of construction logic from the final representation.
Focuses on how classes and objects can be composed to form larger, efficient, and flexible structures.
- Adapter: Allowing objects with incompatible interfaces to collaborate seamlessly.
- Facade: Providing a simplified interface to a complex library, desktop, or subsystem of classes.
- Decorator: Attaching new behaviors to objects dynamically by placing them inside special wrapper objects.
- Proxy: Providing a substitute or placeholder for another object to control access to it.
Focuses on algorithms and the assignment of responsibilities between communicating objects.
- Strategy: Defining a family of algorithms, putting each of them into a separate class, and making their objects interchangeable.
- Observer: Defining a subscription mechanism to notify multiple objects about any events that happen to the object they’re observing.
- Command: Turning a request into a stand-alone object that contains all information about the request.
- State: Allowing an object to alter its behavior when its internal state changes.
Every pattern implemented in this repository is designed to honor the core software engineering pillars:
- Open/Closed Principle (OCP): Code is open for extension but closed for modification through interface-driven design.
- Dependency Inversion (DIP): High-level modules do not depend on low-level modules; both depend on abstractions (interfaces).
- Browse through the pattern categories inside the source folders.
- Each pattern includes a concrete example mimicking a real-world scenario (e.g., Payment Gateways using Strategy, Notifications using Observer).
- Read the inline code comments explaining why a specific abstraction or composition was chosen.