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.

Github Repo

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.
  • 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

Let’s begin!!!


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>