This repository is part of the Refactoring.Guru project.
It contains Swift examples for all classic GoF design patterns.
There are two examples for each of the patterns:
-
Conceptual examples illustrate the internal structure of a pattern, explained with detailed comments.
-
RealWorld examples illustrate how patterns can be used in real-world Swift applications.
For the best experience, we recommend working with examples with Swift 5 and Xcode IDE.
For the sake of simplicity, we tried to limit the scope of these examples to the code, related to the actual patterns. That's why didn't implement full-blown Swift apps, accompanied with Run targets. Instead, our examples are packaged as unit tests, where each Unit Test target executes a specific example of a pattern.
To run an example, browse it in the project directory, select the Unit Test scheme and launch the example.
Client means client of classes, defined as part of a pattern, which is merely a caller of the given methods or a user of the given classes. In other words, it's the part of your application's code that uses the pattern's classes.
Take a look at the structural example first. There you'll find detailed descriptions of each class in a pattern, its role, and connection to other classes.
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
"Design Patterns in Swift" were created by Maxim Eremenko for Refactoring.Guru.