Library Design without Protocols

Section • 3 episodes • 1 hr 24 min

Protocol-oriented programming was first coined by Apple at the 2012 WWDC, and since then it has become the de facto way to create abstractions in Swift. But, as we’ve seen, they have some gotchas. In this section we will build a library from first principles inspired by protocol-oriented programming, and clearly show the downsides to this approach. Then, we’ll scrap the protocols, use simple concrete data types, and discover a whole new world of composition.

Related content

After showing how to build a snapshot testing library using the technique of protocol witnesses we open sourced the library! In this episode we take a tour of the library to show how easy it is to add to your project, and how to get broad test coverage very quickly.

A Tour of Snapshot Testing
29 min

We used our snapshot testing library, in conjunction with the composable architecture, to get integration test coverage on a SwiftUI application. We are able to play a series of user actions and take a screenshot of the UI after each step.

SwiftUI Snapshot Testing
34 min