Giter Site home page Giter Site logo

design-patterns-cpp's Introduction

Design Patterns in C++

This repository is part of the Refactoring.Guru project.

It contains C++ examples for all classic GoF design patterns. Each pattern includes two examples:

  • Conceptual examples show the internal structure of patterns with detailed comments.
  • RealWorld examples show how the patterns can be used in a real-world C++ application.

Requirements

The examples were written as cross platform console application using c++17. It means that you should be able to compile and execute those examples with any recent compiler.

we recommend working with Visual Studio Code because it is a lightweight and cross-platform tool .It is a very complete IDE and is available for free (https://code.visualstudio.com/). You may need to install c++ extension and the compiler you prefer (The extension is still in preview and its focus is code editing, navigation, and debugging support for C and C++). For more information on how to use VSCode with c++ refer to: https://code.visualstudio.com/docs/languages/cpp .

For code execution in VSCode you will need to set up your task first. An example using g++ :

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "g++ -g -std=c++17 Conceptual/main.cc -o main",
            "group":{
                "kind": "build",
                "isDefault": true    
            },
            "problemMatcher":"$gcc"
        }
    ]
}

Then you just need to start the executable. In case you have some doubts here you have an useful tutorial using vscode.

Contributor's Guide

I appreciate any help, whether it's a simple fix of a typo or a whole new example. Just make a fork, make your change and submit a pull request.

Here's a style guide which might help you to keep your changes consistent with the rest of the project's code:

  1. All code should match the Google style guide.
  2. Aim to put all code within one .cc file. Yes, I realize that it's not how it supposed to be done in production. However, it helps people to understand examples better, since all code fits into one screen.
  3. The comments doesn't follow the style guide for compatibility reasons with other language examples.

License

This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.

Creative Commons License

design-patterns-cpp's People

Contributors

danieldewberry avatar ederfduran avatar isergeyam avatar m1te5h avatar mynickmynick avatar neochief avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

design-patterns-cpp's Issues

Switch to Using Modern C++ Classes

I noticed a lot of raw pointer usages throughout the examples. I wanted to go through and fix it up to use unique_ptr and shared_ptr where appropriate. Would there be any objections to that? What about using some of the more modern language versions like C++14/17/20? Newer compilers don't support the C++11 flag anymore and default to C++14 considering the C++11 standard is now 10 years old. Is there any minimum compiler requirements being targeted by these examples?

Fill-in the Readme.txt

Note: you can always look at our other example repositories for guidance, mainly C# repo.

  1. Investigate what's the current C++ compiler version, what are the main tools, IDEs, etc. Document this in README.

  2. Investigate C++ code style conventions, pick the best one and document it in the readme.

2.1. Decide what will be the folder structure.

2.2. Decide what will be the name of the output files.

2.3. Decide what will be the format for localized code comments.

Remember that the examples are better be done cross-platform. Even if we stick to Visual Studio conventions, examples should be compilable with opensource compilers from Linux.

Where could I find the other patterns?

I find only conceptual pattern here. Or it wasn't checked in for commercial reasons? If anybody wants to buy your book, does man also get the complete code source?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.