Protocol-Oriented Programming in Swift
Практическое руководство по протоколам Swift
Resumo:
Introduction
The book "Protocol-Oriented Programming with Swift" (2015) by Jon Hoffman is one of the first publications dedicated to the protocol-oriented programming (POP) paradigm in the Swift language. Swift was originally designed as a protocol-oriented language, and the author thoroughly explains how to use protocols, extensions, and composition instead of traditional class inheritance. The book will be useful for iOS and macOS developers who want to write more flexible, testable, and reusable code.
What the book is about
The book consists of 10 chapters, each covering a specific aspect of POP. It starts with the basics: what protocols are, how to declare them, and how to conform to them. Then the author moves on to more advanced topics: protocol extensions, protocol composition, using protocols with generics, and comparing POP with OOP. Special attention is given to practical examples — building a game engine, working with delegates, and design patterns.
Who this book is for
The book is aimed at developers who are already familiar with the basics of Swift and have experience building applications for iOS or macOS. Beginners will find it challenging — knowledge of syntax, data types, and basic OOP is assumed. However, for those who want to move from classical inheritance to a more modern approach, the book will be an excellent guide.
What the reader will learn
- Protocol basics: declaration, conformance, required and optional