I’m currently reading Refactoring to Patterns (affiliate link). Yesterday, when I wrote about the Creation Method for an object that has a lot of parameters, it made me think of @modocache‘s amazing talk on Swift Patterns in iOS API Design, specifically the part of about Parameter Objects. This has come up for me a few times since I initially saw the talk, so I wanted to document it here.
As I spoke at and attended several conferences last month, the book Refactoring to Patterns (affiliate link) kept coming up again and again, especially in my favorite talks. I finally have a little time to read it (before all the after-WWDC-announcement craziness ascends), and I’d like to document the patterns I like for future reference. I also found it better to remember the information by translating the Java in the book to Swift. The first pattern is the Creation Method.
It's a common pattern in Swift (and a really nice one!) to configure constants right when they are initialized in a closure vs later on in a viewDidLoad or another such method... but it can get awkward!
I recently gave a talk on Practical Protocol-Oriented-Programming(POP💥) in Swift. The video is still being processed. Meanwhile, here is the written-up version of the POP View part of the talk for reference (for me and anyone else!).
I recently gave a talk on Practical Protocol-Oriented-Programming (POP💥) in Swift. The video is still being made. Meanwhile, here is the written-up version of the POP Networking part of the talk for reference (for me and anyone else!).
Notice the thing! Since each View Controller would be injected with something specific – it could be text-based or number-based or array-based, anything! I didn’t know how to name the parameter. So thing seemed like the most fitting parameter name.
I read a comment by @cduhn on my I 💖 Storyboards & Nibs blog post that triggered an idea for a slightly better solution for this...
Starting in Swift 3.0, C-style for-loops will be gone from Swift! Last week, I talked to an iOS developer who was upset by this (it is a long-held habit after all!) and was confused by what to use as an alternative. @twostraws did a great write-up on the new Swift 2.2 features and what to use instead, so I’m going to write it down here for my own (and your) reference.
Since I openly declared my love for Storyboards & Nibs earlier this week, I’ve gotten a lot of questions on how I deal with injecting dependencies between View Controllers without using a custom initializer. So I’ll share that now. But first...
I’ve seen Phantom Types before, including in this objc.io article about Phantom Types and in conference talks, but while I like the idea of Phantom Types and think they’re cool and interesting, I haven’t actually used them ever in my own code. Mostly, because it’s not yet natural for me to see a problem and think “Ah, Phantom Types would be the perfect solution!” But this example caught my eye...