Skip to content

Latest commit

 

History

History

README.md

Design Patterns - Elements of Reusable Object-Oriented Software

Overview

UNDER CONSTRUCTION

under constructon sign

What, Why, and Who?

What are Design Patterns?

Design patterns are typical solutions to commonly occurring problems in software design. They are like pre-made blueprints that you can customize to solve a recurring design problem in your code.

All patterns can be categorized by their intent, or purpose, for further reading please refer to this section.

Why Design Patterns?

Because design patterns are a toolkit of tried and tested solutions to common problems in software design. They're like learning color blends instead of just trying out every pair of colors to get a desired color (solution).

Who came up with Design Patterns?

A history lesson here,

Short answer; Erich Gamma, John Vlissides, Ralph Johnson, and Richard Helm, back in 1994.

Better answer:

Design patterns gained popularity in computer science after the book Design Patterns: Elements of Reusable Object-Oriented Software was published in 1994 by the so-called "Gang of Four" (Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides), which is frequently abbreviated as "GoF".

References

Learn more on design patterns at Refactoring.Guru and Wikipedia.

Book Implemented

This is my implementation of the Design Patterns from the book

'Design Patterns: Elements of Reusable Object-Oriented Software'
Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides
ISBN 0-201-63361-2
Copyright 1995
21th Printing, November 2000

The nice thing about the Design Patterns book is that it is... well... not complete :-) To come to a complete working implementation of all the Design Patterns presented in the book and be able to play with them, requires some extra coding. The goal of this project is to actually provide the missing pieces and come to something that will compile and run cleanly.

On the following websites, I have found C++ code that helped me complete everything:

And here are some interesting slides that give some more explanation:

A more modern C++11 approach using Boost libraries was given in a talk by Tobias Darm given here:

An interview from 2009 with the GoF authors is given here:

A dependency analysis and refactoring of the Gang of Four examples can be found at

What's inside

Implemented Design Patterns so far:

Behavioral Patterns
  • Chain of responsibility
  • Command
  • Iterator (aka Cursor)
  • Observer
  • Strategy
  • Template Method
Creational Patterns
  • Abstract Factory
  • Builder
  • Factory Method
  • Prototype
Foundation Classes
Structural Patterns
  • Adapter

Requirements and Build

Requirements:

  • Cmake
  • C++ compiler

How to build

Each category has its own cmake file, hence you will need to change directory to the desired category cd, run the following commands one by one:

cd {Category_dir}/
cmake -S . -B build
cmake --build ./build
...

You can also use CMake's -j N option for parallel builds on N cores and -v for verbose builds:

cmake --build build -j 4 -v

Note

Replace {Category_dir} with the actual directory name.