Back to Basics: Object-Oriented Programming
summary
Argues that runtime polymorphism in C++ still matters for “millions” of legacy users and gives concrete rules: model public inheritance as an is-a relationship, make non-leaf classes abstract (pure virtuals) to avoid slicing, use the non-virtual interface so base pre/post work is enforced, always declare destructors virtual or deleting via base is undefined, mark overrides with override, avoid mixing overloading and overriding, don’t call virtuals in constructors/destructors, prefer dynamic_cast for downcasts but refactor to eliminate casts. Example: console/file/SMS logger shows surprising compile-time defaults and ctor dispatch.
AI-written summary · about
chapters (52)
- 0:00Intro
- 2:46Agenda
- 3:38Definition
- 3:53Alternatives
- 4:41ObjectOriented Programming
- 5:13Logging
- 6:35Base Class
- 7:17Client Code
- 9:14Loggers
- 9:57Subtype
- 10:44Surprise
- 10:59Why is this important
- 11:54Herb and Andre
- 12:32Virtual Dispatch
- 12:49Design Best Practices
- 13:26Public Inheritance Models
- 13:52Derived Classes
- 14:46Logging and Display
- 15:54Nonleaf Classes
- 18:35Scotts Solution
- 19:14Scots Guideline
- 23:28Nonvirtual interface idiom
- 23:53Nonvirtual logger
- 24:40Pre and post
- 25:44Each interface can take its natural shape
- 27:28Public virtual has two responsibilities
- 27:42Public virtual has one responsibility
- 27:52Nonvirtual interface
- 28:37Best practice
- 28:48Build things
- 29:31Test
- 31:10Create a file logger
- 32:02Make base class instructors virtual
- 32:34Virtual keyword
- 32:49Log message
- 33:04Override
- 33:56Scopes
- 34:59Drive classes
- 35:35Function overloading
- 37:38Dont mix overloading and overriding
- 37:55Avoid hiding inherited names
- 39:35Should Derived classes have a default
- 39:59DIY violation
- 40:32Overloading
- 43:41Virtual Functions
- 44:12SMS Logger API
- 45:39Upcast
- 46:20Downcast
- 46:34Static Cast
- 47:41Dynamic Cast
- 50:41Minimize Cast
- 51:53Questions
related talks
58mOO Considered Harmful
38mWhat Object-Oriented Programming Was Supposed to Be: Two Grumpy Old Guys’ Take on ...
55mHow to "OO" in C++
01h 18mAbstraction: The True Superpower of C++
54mWriting C++ to Be Read
01h 23mRethink Polymorphism in C++
01h 22mSimplicity: not just for beginners
01h 35mRuntime Polymorphism: Back to the Basics
