Free Your Functions!
summary
Argues that C++ code favors non-member, non-friend free functions because they reduce coupling, improve encapsulation, follow SRP and Open‑Closed, enable reuse via overloading and templates, and simplify testing without friends; cites std::begin/std::real as practical examples and Chandler Carruth optimization example showing member functions add an implicit this pointer that can prevent ideal registerization; advises namespaces/detail, ADL care, and Scott Meyers’ rule (virtual or private-access → member; otherwise prefer non-member).
AI-written summary · about
chapters (26)
- 0:00Introduction and hypothesis
- 3:13SOLID principles recap
- 5:23Encapsulation and member functions
- 7:51Coupling and private member functions
- 10:47Single Responsibility Principle
- 11:54Open-Closed Principle and extensibility
- 13:16Reuse and DRY principle
- 15:05Static polymorphism and function overloading
- 18:22Abstraction and testability
- 22:17Performance and compiler optimizations
- 25:49Summary of advantages
- 27:16Standard library examples
- 30:57Why free functions work
- 33:08Function encapsulation and namespaces
- 35:58IDE support and uniform call syntax
- 39:14Finding and organizing free functions
- 41:01ADL and potential issues
- 44:14Virtual functions and free functions
- 45:38Functional programming and paradigms
- 47:04Should member functions be avoided?
- 48:30Scott Meyers' decision algorithm
- 50:01Teaching C++ and member functions
- 51:27Free functions vs C-style programming
- 52:09STL and SOLID principles
- 55:37Conclusion and call to action
- 55:58Q&A session
related talks
04mKeep Your Friends under control
01h 01mValue Oriented Programming. Part 1: You Say You Want To Write A Function
54mWriting C++ to Be Read
01h 01mSome Programming Myths Revisited
01h 23mThis is C++ - How to Use the C++ Superpower to Write Better C++ Code
01h 01mEasy to Use, Hard to Misuse: Declarative Style in C++
58mOO Considered Harmful
01h 00mBack to Basics: Object-Oriented Programming
