Learning and writing Swift code is kind of fun!
The new Apple language, Swift, extends Objective-C not only from the horizontal (like clean code strcuture, adding support to generics, etc.), but also from the vertical (like introducing more powerful enumeration and strcuture, using optional to deal with “nil”, etc.).
In this series of “Design Patterns in Swift”, I’m trying to review the whole 23 design patterns (orginally introduced in the book of GOF – “Design Patterns: Elements of Reusable Object-Oriented Software“) and also write some examples in Swift.
Another fun journey of learning Swift.
For each of the following post, I will include all related materials in the Github repo – https://github.com/cowfox/design-pattern-swift.
The repo is organized by the three major purposes of deisgn patterns:
- Creational, concern the process of object creation.
- Structural, deal with the composition of classes or objects.
- Behavioral, characterize the ways in which classes or objects interact and distribute responsibility.
For each of the patterns, it contains:
- General annotation about the deisng pattern.
- Example code in Swift.
- The code is shipped by Xcode Playground, including the annotation part.
- Related lass / object diagram (in UML).
- The UML diagram is created by StarUML.
- Design Patterns: Elements of Reusable Object-Oriented Software, by Book by Erich Gamma, John Vlissides, Ralph Johnson, and Richard Helm (GoF)
- Pro Objective-C Design Patterns for iOS, by Carlo Chung
- Pro Design Patterns in Swift, by Adam Freeman