When Apple introduced Swift, it also introduced a slogan: “Swift is a protocol-oriented language.” Instead of building deep class hierarchies, you describe capabilities with protocols, give them default behavior with extensions, and let any type, whether a struct, an enum, or a class, adopt exactly the capabilities it needs.

Most of the Swift standard library works this way, from Equatable and Hashable to Sequence and Collection. This guide shows how to use the same approach in your own code.

Article available Coming soon

1. Why Not Just OOP?

2. Protocol Basics

Protocols in Swift

A protocol describes what a type can do, without saying how. Classes, structs, and enums can all adopt protocols, which makes them...

3. Protocol Extensions

4. Protocols and Generics

Generics in Swift

Generics let you write code once and use it with many types, without giving up type safety. Array<Element>, Dictionary<Key, Value>, Optional<Wrapped>, and...

5. Errors and Protocols

Error Handling in Swift

Things go wrong: files are missing, networks drop, users type nonsense. Swift handles recoverable errors with throw, try, and catch, a model...

6. Design Patterns, the Protocol Way

7. Putting It Into Practice

Up next

Functional Programming

This guide grows with the blog: new articles are linked here as soon as they're published. Missing something? Let me know.

← Back to all roadmaps