Easy to use, hard to misuse: Practical guidelines to tame your API
summary
Argues that strong types help but are not a silver bullet and shows concrete alternatives: named constructors, tagging enums and nested builder classes used to disambiguate Date/Point construction; gives a rule of thumb to introduce wrapper types only if many real classes use them. Classifies misuse by detectability (compile, immediate crash, prototype, docs) and demos a transaction-handle RAII trick and why a single set_date is safer than multiple setters. Covers error reporting (exceptions vs two‑phase vs expected/flag) and using no_discard wrapper for safer APIs; insists names reflect altitude in the call stack with real bug examples (failed_connect_count logic, extra_configuration doing too much).
AI-written summary · about
chapters (13)
- 0:00Introduction to API design
- 1:04Problem with implicit assumptions
- 3:53When strong types help or hurt
- 5:41Classifying API misuse difficulty
- 7:25Worst case: relying on comments
- 10:34Designing safer APIs
- 12:44Common way should be safe way
- 15:16Handling bad dates
- 18:52Flag-based initialization pitfalls
- 23:31Importance of naming in APIs
- 26:18Naming functions by context
- 30:51Real-world API misuse examples
- 32:16Summary and final thoughts
