API design: Lessons Learned
summary
Practical, code-level takeaways: when building APIs use double-underscore to protect internals so subclasses can’t break invariants, expose extension points instead of hardwiring behavior (provide hooks not hardwired behavior), prefer multiple constructors via classmethods for different call patterns, avoid over-eager coercion of input types (floats-as-indices), use decorators like recursive_repr to handle edge cases, design an async protocol rather than a concrete implementation, and avoid global state like setlocale.
AI-written summary · about
chapters (16)
- 0:00Introduction
- 2:55API design principles
- 13:37Balancing forces
- 19:24Subclassing and extensibility
- 27:30Open-closed principle
- 33:22Double underscore methods
- 40:26Ask forgiveness not permission
- 44:48Hiding internals
- 50:51Decorators and recursion
- 57:16Recognizable behavior
- 1:00:05Context-dependent design
- 1:01:29Multiple constructors
- 1:07:23Design failures
- 1:13:07Async core protocol
- 1:14:51Global state pitfalls
- 1:17:00Q&A
related talks
01h 05mAPI design - tips from practice
47mAPI Design Principles
27mAPI Design Through the Lens of Photography
01h 01mAPI Design – How to Do It Better (and How Not To)
01h 36mThe Most Important API Design Guideline - No, It's Not That One
41mThe making of a great API
23mDesigning APIs for humans
51mAPI Design in Real Life: What You Don't See in Books
