This repository contains C++ implementations of classical Object-Oriented Design Patterns, developed as part of the OOP2 (Object-Oriented Programming 2) course.
The goal of this project is to demonstrate how and why design patterns are used, using clear, minimal, and educational C++ examples.
Each folder represents one or more design patterns, implemented independently for clarity and learning purposes.
Patterns are grouped according to the Gang of Four (GoF) classification:
- Creational
- Structural
- Behavioral
Creational patterns focus on how objects are created, helping to make a system independent of how its objects are instantiated.
Ensures that a class has only one instance and provides a global access point to it.
Used when exactly one object is needed to coordinate actions (e.g. configuration, logging).
Separates the construction of a complex object from its representation.
Allows the same construction process to create different representations.
Defines an interface for creating objects, but allows subclasses to decide which class to instantiate.
Promotes loose coupling by eliminating direct object creation.
Provides an interface for creating families of related objects without specifying their concrete classes.
Useful when systems must be independent of how products are created.
Creates new objects by cloning existing ones, rather than instantiating new classes.
Efficient when object creation is expensive or complex.
Structural patterns deal with how classes and objects are composed to form larger structures while keeping them flexible.
Allows incompatible interfaces to work together by converting one interface into another expected by the client.
Decouples an abstraction from its implementation so that both can vary independently.
Composes objects into tree structures to represent part–whole hierarchies.
Allows clients to treat individual objects and compositions uniformly.
Dynamically adds new responsibilities to objects without modifying their structure.
A flexible alternative to subclassing.
Provides a simplified interface to a complex subsystem, reducing dependencies.
Provides a placeholder or surrogate for another object to control access to it.
Behavioral patterns focus on communication between objects, defining how responsibilities are distributed.
Provides a way to access elements of a collection sequentially without exposing its internal structure.
Defines a representation for a language grammar and an interpreter to evaluate sentences in the language.
Passes a request along a chain of handlers, allowing multiple objects to process the request without coupling the sender to a specific receiver.
Encapsulates a request as an object, allowing parameterization, queuing, and logging of requests.
Defines a one-to-many dependency so that when one object changes state, all dependents are notified automatically.
Centralizes complex communications between objects into a mediator, reducing direct dependencies.
Allows an object to change its behavior when its internal state changes.
The object appears to change its class.
Defines a family of algorithms, encapsulates each one, and makes them interchangeable at runtime.
Defines the skeleton of an algorithm, allowing subclasses to redefine specific steps.
Separates algorithms from object structures by moving operations into a visitor object.
Captures and restores an object’s internal state without violating encapsulation.
- Learn object-oriented design principles through real implementations
- Understand when and why to apply each design pattern
- Improve code:
- Maintainability
- Flexibility
- Readability
- Practice clean C++ design
- Language: C++
- Paradigm: Object-Oriented Programming
- Key concepts:
- Interfaces (abstract base classes)
- Polymorphism
- Composition over inheritance
- SOLID principles
- Decoupled architecture
- Clone the repository:
git clone https://github.com/MarkoMilenovic01/Design-Patterns.git