Alex Ozun: Type-Driven Design with Swift (SwiftCraft 2024)
Type-Driven Design with Swift by Alex Ozun from this year’s SwiftCraft is a recommended watch.
Alex covers concepts like replacing the notion of validation user input (with true/false results to represent its validity) with the notion of parsing – transforming unprocessed values into processed ones that uphold certain guarantees, like matching a string pattern. For example for email addresses.
The biggest idea tying all of the things Alex covers together is iteratively using Swift’s strong type system to sketch and then build a domain that ensures certain classes of mistakes are impossible to make. Because if you would try to do them, the compiler would complain.
I also put into my Zettelkasten a couple of concepts that didn’t have a home before, like
- Black hole arguments to express requirements in types;
- the idea that only compilation errors prevent faults in production;
- “Type, Define, Refine” flow to give iterative type-writing a name;
- that we can achieve type unions in Swift via enums;
- the idea of “Parse, Don’t Validate”.