Object-Oriented Program: Best Practices
summary
Defines OOP specifically as runtime polymorphism via virtual functions and explains vtable dispatch and its small overhead; gives concrete rules: use inheritance for is‑a relationships not code reuse, make non-leaf classes abstract and leaf classes final, protect base assignment to avoid slicing, always give polymorphic bases virtual destructors, tag overrides with override, avoid default parameter defaults in overrides, never call virtuals from constructors/destructors, and prefer dynamic_cast for safe downcasts or refactor to add a base virtual hookup (NVI) instead.
AI-written summary · about
chapters (19)
- 0:00Intro
- 1:10ObjectOriented Programming
- 4:27Theory
- 9:21Pure Client
- 11:32Subtype Requirement
- 13:09Our Goal
- 14:52How Does It Work
- 16:14Vtable
- 23:08Guidelines
- 23:32Inheritance
- 27:48Public Inheritance
- 28:57Nonleaf Classes
- 34:05Scotts Solution
- 34:32Class Types
- 34:52Derivation
- 37:17Shallow Hierarchies
- 39:01Concrete Hierarchies
- 43:45Nonvirtual Interface
- 47:02Natural Shape
related talks
55mHow to "OO" in C++
01h 01mValue Oriented Programming. Part 1: You Say You Want To Write A Function
58mBetter Code: Runtime Polymorphism
47m“Intro to the C++ Object Model"
01h 02mOn the benefits of non-intrusiveness
01h 23mRethink Polymorphism in C++
01h 07mDynamic Polymorphism With Code Injection and Metaclasses
01h 26mC++ Under the Hood: (Internal Class Mechanisms)
