The State pattern, made simpler and more flexible with the power of Swift, with a detailed worked example to illustrate handling of new requirements, also looking at key design and implementation considerations and the benefits and practical applications of the pattern.
Covers a host of powerful Swift language features and associated techniques that enable us to use optionals in a completely safe manner, also looking briefly at unsafe practices that are best avoided when dealing with optionals.
Looks at how optionals in Swift can help us better model real-world domains and write more robust and expressive code, covering why Swift has optionals, basic optional syntax, how optionals are actually implemented and practical uses of optionals in Swift programming.
Shows how to implement conditional logic using conditional statements as well as data structures, types and flow control mechanisms such as loops, balancing simplicity and clarity with flexibility and future-proofing.
Shows how to leverage the power of Swift value types to manage domain complexity by creating rich domain-specific value types to encapsulate domain logic and business rules, keeping classes lean and focused on maintaining the identity of entities and managing state changes through their life cycles.
Covers use of the Numeric protocol as a constraint on type parameters of generic types to ensure that certain type parameters can only be used with numeric types, using protocol composition to add relevant functionality as required.
Examines the likely sources of errors in an application, some ways to prevent errors from occurring and how to implement error handling, using the error handling model built into Swift, covering the powerful tools, associated techniques and how to apply them in practice to build robust and resilient applications.
Covers the Command Pattern in detail, including the classic implementation, a modern makeover and two brief case studies to show how the pattern can be implemented in a contemporary way using Swift while retaining the character of the pattern, its benefits and practical applications.
Explores the semantic differences between value and reference types, some of the defining characteristics of values and key benefits of using value types in Swift, leading into a discussion on how value and reference types play a complementary role in modeling real-world domains and designing applications.
Uses type erasure to implement Equatable conformance at the protocol level, allowing us to program to abstractions using protocol types while safely making equality comparisons and using functionality provided by the Swift Standard Library only available to types that conform to Equatable.
Shows how making protocols conform to Equatable renders us unable to use the protocols as types and why trying to implement equality functions on protocols, even without Equatable conformance, can lead to erroneous results in some cases and is impossible in others.