Posts

Showing posts from April, 2017

Keep your option(al)s open

Image
I'm a Swift Newbie. And its humbling to say the least. But I'm definitely seeing parallels with other object oriented programming languages such as Java. One prime example is the Optional type. optionals were recently introduced to  the Java development ecosystem (JDK8) But as any Java developer would know, third party libraries such as Guava supported the optional type way before Java 8 was a thing. Guava, anyone? No, not the fruit. Check this out  for more on Guava optionals specifics. The resource also highlights some common regrets with nulls in general. In a nutshell, they suck! (thanks Doug Lea for the quote!) In short, optionals give us the option (see what I just did there) to store an existing value of a specific type or nothing at all. For example, let's say we want a variable to hold someone's middle name. Not everyone has a middle name so we want to allow the possibility of a missing value. So I want a variable called middleName to hold a person's mi