turing complete with a stack of 0xdeadbeef

Writing by tag: enums

Enums as configuration: the anti-pattern

Implementing the open/closed principle 31 July 2016

One of the most common patterns I see in software design with Objective-C (and sometimes Swift), is the use of enumeration types (enum) as configurations for a class. For example, passing an enum to a UIView to style it in a certain way. In this article, I explain why I think this is an anti-pattern and provide a more robust, modular, and extensible approach to solving this problem.

Continue…

Swift enumerations and equatable

Implementing equatable for enums with associated values 26 July 2015
Updated: 03 January 2021

Recently, I came across a case (pun intended) where I needed to compare two instances of an enum type in Swift. However, it was an enum where some cases had associated values. At first glance, it is not obvious how to do this.

Continue…