Practical Design Patterns in Swift
2h 36mIntermediate2019-04-05
Authors

Károly Nyisztor
Mobile Developer, Instructor
Course details
The “Gang of Four” software design patterns have been around for decades. There’s a good reason they’re still so popular today. These patterns embody proven best practices that result in more functional, robust, and future-proof code. In this course, instructor Károly Nyistor teaches you how to implement the most useful design patterns in Swift, using features like protocol-oriented programming, type extensions, and value types. Learn about their benefits and limitations and then explore each group of patterns in detail. Károly reviews creational patterns such as Singleton, Prototype, and Factory Method; structural patterns including Adapter, Façade, and Proxy; and behavioral patterns such as Chain of Responsibility, Iterator, Observer, and State. Each tutorial includes coding examples that show how to implement the patterns in real-world projects.
Learning objectives
Why use design patterns?
The limits of design patterns
Using the Singleton pattern
Coping and cloning with the Prototype pattern
Polymorphic instantiation with Factory Method
Iterating with the Iterator pattern
Removing dependencies with the Observer pattern
Reducing complex conditional logic with the State pattern
Learning objectives
Why use design patterns?
The limits of design patterns
Using the Singleton pattern
Coping and cloning with the Prototype pattern
Polymorphic instantiation with Factory Method
Iterating with the Iterator pattern
Removing dependencies with the Observer pattern
Reducing complex conditional logic with the State pattern
Skills covered
SwiftSoftware DesignAppleProgramming LanguagesSoftware DevelopmentDeep Dive (X:Y)
Concepts
0. Introduction
- 01 - Explore the benefits of design patterns
- 02 - What you should know
1. Design Patterns - Values and Limitations
- 03 - What s a software design pattern
- 04 - Applications of design patterns
- 05 - Limitations
- 06 - Creational, structural, and behavioral patterns
2. The Singleton Pattern
- 07 - Purpose, pros, and cons
- 08 - Read-only singletons
- 09 - Concurrency issues
- 10 - Making the singleton thread-safe
- 11 - Readers-writer lock
3. The Prototype Pattern
- 12 - Purpose - Cloning
- 13 - Copying value types
- 14 - Pitfalls of cloning reference types
- 15 - Cloning reference types
4. The Factory Method Pattern
- 16 - Polymorphic instantiation
- 17 - Implementing the Factory Method
5. The Adapter Pattern
- 18 - Working with incompatible interfaces
- 19 - Classical Adapter
- 20 - Adapter using type extensions
6. The Decorator Pattern
- 21 - Enhancing a type without modifying it
- 22 - The object Decorator
- 23 - Decorator via Swift extensions
7. The Facade Pattern
- 24 - Purpose - Simplify usage
- 25 - Consolidating complex functionality
8. The Flyweight Pattern
- 26 - Sharing of common data
- 27 - Spaceships
9. The Proxy Pattern
- 28 - The surrogate
- 29 - Delayed initialization
10. The Chain of Responsibility Pattern
- 30 - Request propagation
- 31 - Request processor
11. The Iterator Pattern
- 32 - Sequential access
- 33 - Custom queue implementation
- 34 - Adding for-in loop support to the queue
12. The Observer Pattern
- 35 - Broadcasting
- 36 - Notifying observers
13. The State Pattern
- 37 - Aim - Reduce complex conditional logic
- 38 - Coffee machine with nested conditionals
- 39 - Refactoring - Identifying the states
- 40 - Refactoring - Implementing the states
Conclusion
- 41 - Next steps
Related courses
- Code Clinic: Swift
- Composable SwiftUI Architecture Using Redux: 2 Building the App
- Mastering Self-Motivation
- Generative Analysis: The Power of Generative AI for Object-Oriented Software Engineering with UML by Pearson
- GitHub Copilot for Cybersecurity Specialists by Microsoft Press
- Agentic AI Economics: Business Models and Pricing Strategies
- Python: Advanced Design Patterns (2018)
- Python: Advanced Design Patterns