Collection of various design patterns with example implementation in C++. Creational, Structural and Behavioral design patterns have been implemented. This also includes some of the commonly used Idiom in C++ programming. This is just to demonstrate the usage of the design patterns.
Note: Code is NOT optimized but is used as a part of knowledge sharing.
Pattern Name | Description |
---|---|
Factory Method | General object construction is replaced with a specific method |
Abstract Factory | Group of related class without specifying concrete implementation |
Builder | Stepwise construction of Complex objects |
Prototype | Object constructed from a prototype |
Singleton | Build Class with single instance |
Pattern Name | Description |
---|---|
Adapter | Link Objects with incompatable interfaces/classes |
Bridge | Decouples Abstraction and implementation |
Composition | Build Object into tree like structures |
Decorator | Adding additional Features to existing objects dynamically |
Facade | For providing simple interface for complex libraries |
Flyweight | Sharing the common data between multiple objects |
Proxy | Controlled access to original object |
Pattern Name | Description |
---|---|
Chain of Responsibility | Handle Request/Data by multiple configurable Handlers |
PIMPL | Pointer to Implementation |
Command | Convert Requests as Objects for Handling |
Iterator | Traverse elements in collections without exposing |
Mediator | Collabration between objects via a mediator |
Memento | Saving and Restoring the state of an Object |
Observer | Notify Events between objects having one to many relationship |
State | Alter the Objects behaviour when internal parameters change |
Strategy | Run-time changing of objects inturn changing behaviour |
Template | Provides Skeleton in superclass allowing some of the steps to be overriden by subclasses |
Visitor | Add new operations without changing the existing code |
git clone https://github.com/jayavardhanravi/DesignPatterns.git
In this project I used Visual Studio 2017. Choose and build the specific design pattern either in Debug or Release
Books | |
---|---|
Book Title | Design Patterns Elements Of Reusable Object-Oriented Software |
Book Publisher | Addison-Wesley |
Publication Year | 2016 |
BSD 2-Clause License
Copyright (c) 2020, Jayavardhan Ravi All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.