Swift Best Practices in Your iOS Apps
March 18 & 19, 2019
Getting the most from Swift 5.0 in your iOS 12 Apps
This intermediate course is for iOS programmers who know the fundamentals of the Swift Programming Language but haven't mastered the paradigms.
What you'll learn
We build up a simple multi-scene application that surrounds a functional non-mutating core with an OO GUI. The point of the two days is not, of course, the example but is instead the collection of techniques we explore along the way.
We begin by test driving the design of our model and add support for generics using conditional conformance. We then drop our model into a simple table view application. We add a second scene using closures to communicate information and functionality across different scenes, storyboards, and modules.
Swift gives us many techniques for addressing what to do when things go wrong. In the next section we'll look at Optionals, asserts and preconditions, Swift's Error type, and Swift 5's new Result type.
Next we focus on the functional aspects of Swift by looking at map, flatMap, filter, reduce, and friends for collections. We'll use many of these techniques when we work with Strings now that they are again collections (with a default encoding). We'll finish the course by making asynchronous calls to fetch and process JSON using the new Codable protocol and finish with a simplistic implementation of Futures.
Thinking Functionally in Swift 5.0
March 20, 2019
This course is for experienced Swift developers who want to explore Functional Programming.
What you'll learn
At the end of this day, you'll look at functions differently. Actually, you'll look at functions differently from the very start of the day when we express Sets and Pictures using structs that contain nothing more than a single property that is a closure.
Next, we review the map() function for arrays and generalize the concept to map for Optionals, Swift 5's new Result type, and our own type. The goal is for you to see map as a design pattern.
A type that supports map is a Functor and one that supports flatMap is a Monad. In our third section we'll look at two flatMaps that are part of the Swift standard library and a third that has been renamed to compactMap. You'll understand why this renaming was a good idea and you'll come to appreciate where we want to use a flatMap.
Our final section looks at a higher-order function that is somewhere in between map and flatMap: apply. In some ways apply is more powerful than flatMap and we'll see that in some situations we get a lot of return with very little effort.
We assume that you are an experienced programmer who has spent some time looking at Swift but you are relatively new to Functional Programming.