Skip to content

galudino/gof-designpatterns-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gof-designpatterns-cpp

Table of contents

About

This repository consists of design patterns/sample code described in
Design Patterns - Elements of Reusable Object-Oriented Design
by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides

Design Patterns is also known by the community as GoF, aka Gang-of-four. (four authors)

The sources were taken straight from the textbook -- but I plan to refactor some of the code
for modern C++, and as well as adapting the code to my preferred naming convention for C/C++ sources.

Note: This repository is a work in progress. I need to:

  • Transfer code from the textbook to respective folders/source files in this repo
  • Refactor code for my preferred naming convention
    • (I'll be using snake_case, as opposed to camelCase or PascalCase.)
  • Look for places where I can adapt the code to modern-C++.

My purpose is to:

  • refresh/refine my understanding of the design patterns in GoF,
  • log my progress along the way
  • and have a catalogue of sources to easily browse/run at my convenience.

(back to table of contents)

Design Pattern sources

(back to table of contents)

(back to table of contents)

(back to table of contents)

(back to table of contents)

Building

Run the included makebuilds script to have cmake
create Unix-Makefile builds in the following modes:

  • Debug
  • Release
  • MinSizeRel
  • RelWithDebInfo
% ./makebuilds

A build/make subdirectory will be created with subdirectories
of the modes described above.

If we want to create a Debug build of the program in the demo directory
(which will also build the sources in the src directory):

make -C ./build/make/Debug/demo

Generally, you would invoke make as follows:

make -C ./build/make/[build-mode]/[target-name]

After running make, you can run the demo executable:

./build/make/Debug/demo/demo

Generally:

./build/make/[build-mode]/[target-name]/[executable-name]

The makebuilds script (without comments/newlines) looks like this:

#!/bin/zsh

## Remove any previous build folders
rm -rf ./build/make/Debug/* || true
rm -rf ./build/make/Release/* || true
rm -rf ./build/make/RelWithDebInfo/* || true
rm -rf ./build/make/MinSizeRel/* || true || true

cmake -S ./ -B ./build/make/Debug -DCMAKE_BUILD_TYPE=Debug
cmake -S ./ -B ./build/make/Release -DCMAKE_BUILD_TYPE=Release
cmake -S ./ -B ./build/make/RelWithDebInfo -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake -S ./ -B ./build/make/MinSizeRel -DCMAKE_BUILD_TYPE=MinSizeRel

(back to table of contents)

Alternate build systems

If you want to use an alternative build system, i.e. Xcode or Visual Studio
(see the list of supported generators on your system using cmake -help), invoke the following:

% cmake -S ./ -B ./build/[generator-name] -G "[generator-name]"

For example, for Xcode:

% cmake -S ./ -B ./build/xcode -G "Xcode"

(back to table of contents)

About

Design Patterns - Elements of Reusable Object-Oriented Design (GoF), in C++

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages