Tag Archives: patterns

Design Patterns in Swift: Observer

      3 Comments on Design Patterns in Swift: Observer

Continuing on our journey with design patterns, this week we’ll visit the observer pattern. This is a really simple pattern to implement. We’ll quickly go through some theory and get down to business. Hopefully, by the end of the article, you’ll be using the pattern in your projects. The Observer… Read more »

Design Patterns in Swift: Abstract Factory

      No Comments on Design Patterns in Swift: Abstract Factory

Abstract factory is one of the creational design patterns. You probably encountered it in your development without realising. Here we’ll cover the swift version of the text-book version of the design pattern and say a few words about the dependency inversion principle. Abstract Factory We’re all taught to code to… Read more »

Unit Tests with Dependency Injection

      1 Comment on Unit Tests with Dependency Injection

A few weeks back I wrote an article on dependency injection and how to use it. Here I’ll cover how to use dependency injection in your unit tests. Dependency Injection I won’t talk a lot about dependency injection in this article, there’s a whole article on the subject, and I… Read more »

Design Patterns in Swift: Singleton

      16 Comments on Design Patterns in Swift: Singleton

Everyone has heard of singletons. It’s probably the simplest design pattern there is, yet, there are a few catches when implementing it. In this post, I’ll go over the singleton design pattern and the little gotchas that might end up in a crash or an inconsistent state of the app. Singleton… Read more »

Using Dependency Injection

      1 Comment on Using Dependency Injection

In this post, we’ll cover one very useful technique called dependency injection and we’ll look at some examples on to use it in your iOS project. What is it? Dependency Injection is a technique where you would inject dependencies into an object. Let’s say you’re building an app that will display… Read more »