GithubHelp home page GithubHelp logo

alecjacobson / better-code-runtime-polymorphism Goto Github PK

View Code? Open in Web Editor NEW
56.0 6.0 2.0 7 KB

Git walk through of the C++ code presented in Sean Parent's talk "Better Code: Runtime Polymorphism"

C++ 100.00%

better-code-runtime-polymorphism's Introduction

Better Code: Runtime Polymorphism

Git walk through of the C++ code presented in Sean Parent's talk Better Code: Runtime Polymorphism.

Casual C++ programmers or CS undergrads will be familiar with the object-oriented code up to the "slide 13" commit. The use of the C++11 feature std::shared_ptr may be new and the memory leak fixed in "slide 13 (leak fix)" may cause a mild surprise. The subsequent transformations go on to show the true power of new C++ features (C++11 and C++14) and the result is very client friendly code (at the price of the library containing some albeit convoluted gobbledygook C++ boilerplate).

The git commits of this repository are labeled with "slide x" where x corresponds to the slide number in the corresponding talk by Sean parent to moments where he compiles and runs the code. Through these commits you will see the transformations he applies. I have mostly faithfully copied his code examples, adding necessary #includes and using namespace lines to get it to compile.

Most of the time the only necessary compilation flag is C++11 support. When unique_ptrs are briefly used you may need C++14.

For example, on Mac OS X with Apple LLVM version 9.1.0 (clang-902.0.39.2) you can compile and run for any commit with

clang++ -std=c++14 client.cpp && ./a.out

better-code-runtime-polymorphism's People

Contributors

alecjacobson 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

xarthurx baysmith

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.