~/talk

Hiding Your Implementation Details in C++ is Not So Simple

Talkat C++ on Sea 2024 · 2024-07-02..07-05· [software-architecture]
slides:none on file

Argues that putting fields private is necessary but not sufficient and shows concrete fixes: replacing public std::pair-style members with getters to allow lazy or changed representation, wrapping associative containers into a mutable-values wrapper so callers can change values but not keys, avoiding protected data in favor of protected functions, preferring interfaces or narrow return concepts over returning std::vector, and using a private-token/passkey idiom to keep constructors public for make_unique while preventing external construction.

AI-written summary · about

  1. 0:00Introduction
  2. 2:36Hiding details complexity
  3. 4:01Public members problems
  4. 7:10Abstraction vs performance
  5. 10:45Context-specific exposure
  6. 13:20Private IDs initially
  7. 15:27Master and dog story
  8. 17:33Lean and decoupled APIs
  9. 21:26Exercise: modify map values
  10. 25:52Solution: wrapper for hiding
  11. 27:18Hide hierarchy and pointers
  12. 31:57State pattern for transitions
  13. 35:27Strategy pattern for algorithms
  14. 36:53Factory methods for types
  15. 37:15Less info in returns
  16. 40:49Interfaces or concepts
  17. 43:38Proxies pitfalls
  18. 45:24Enforce call order
  19. 47:54Protected members rarely justified
  20. 50:44Test private behavior
  21. 52:27Hide types in namespaces
  22. 53:09Private token idiom
  23. 55:16Summary
  24. 56:24Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.