Generic Swift: It Isn't Supposed to Hurt
summary
Argues to write concrete code first and extract protocols later, using extensions as composition rather than class inheritance; replaces URLSession-by-mock testing with a small Transport protocol that wraps URLSession and can be layered (headers, compression, DB backends) for easy unit tests. Shows building requests as plain structs with a data->model function (function-based type erasure) and using a generic Identifier<Model,Value> instead of fragile Int IDs. Warns that PATs and generalized existentials don’t magically solve API design.
AI-written summary · about
chapters (4)
- 0:00Introduction
- 0:27Protocol Oriented Programming
- 29:49Abstracting Networking
- 37:41Equatable and Best Practices
related talks
20mHow Not to Write Swift
15mGenerics
27mGeneric Protocols and Associated Types - Power Tools for Unit Testing
30mLeveraging Swift's Type System
50mWriting Swift code with great testability
55mEmerging Best Practices
48mLearning From Our Elders: Applying functional insights without losing Swift
18mSilver Bullets in Swift
