Quality Coding
Shares

It’s About Time! Quality Coding Embraces Swift

You spoke. The world is shifting. It’s time for Quality Coding to go Swift!

Better late than never.

Swift programming language logo

I want to thank everyone who participated in my 2016 reader survey. Your number one request was clear: “More Swift”.

When Apple first announced Swift, my Twitter feed was filled with folks struggling with the basic tooling. I need to get stuff done, so I waited while the early adopters took the hard knocks. You paved the way. Thank you.

I have yet to work on a team that uses Swift for production code. But I watched Apple’s WWDC 2016 announcements with interest. I’m still playing catch-up on the sessions, but “Swift API Design Guidelines” was noteworthy. An entire session on clean, readable code, and how Swift 3 changes the experience… I’m in! I want that!

So let’s try this. I’m going to start a new version of the Marvel Browser — this time in Swift. I’ll give the Swift version higher priority than the Objective-C version. This will have the following effects:

  • My posting frequency may decrease. I’ve been trying to keep up a weekly cadence this year. Expect bumps in the rhythm.
  • I’ll need your help! My initial attempts at Swift will come from an Objective-C mind. As I write stuff, please don’t hesitate to suggest ways that are more Swifty.

Do you have any tips or suggestions for me as I start? I value your input, so please leave a comment below.

About the Author Jon Reid

Jon is a coach and consultant on iOS Clean Code (Test Driven Development, unit testing, refactoring, design). He’s been practicing TDD since 2001. You can learn more about his background, or see what services he can bring to your organization.

follow me on:
Disclosure: The book links below are affiliate links. If you buy anything, I earn a commission, at no extra cost to you.

Leave a Comment:

10 comments
Steve says last year

Jon,
This is great news! I’m an old Objc developer too, and I just decided a while back to throw myself into Swift and I have to say it’s been a blast. I can’t wait to see how you bring some of your insights on clean code to Swift.

Reply
ignazio says last year

looking forward to see your approach to swift :)

Reply
Paweł says last year

If I may suggest something, go with Swift 3.0, there’s no reason to write almost-legacy 2.2 code version now.

Reply
    Jon Reid says last year

    Good idea — I’ll jump in to the latest. Thanks, Paweł.

    Reply
Yaroslav Smirnov says last year

Only words – “at last”!;) Can’t wait to all these stuff in swift way. In our team we start swift adoption by writing tests on swift, so it’s highly relevant news.

Reply
Dominik Hauser says last year

Good news!
One thing I realised is that mocking is way more verbose. There aren’t any usable mocking frameworks yet. So you will have to create your own mocks and stubs. At least that is what I’m doing.

Reply
    Jon Reid says last year

    Yes, so far Swift seems like, “Hurray, I can type much less production code! Oh, but I have to type a lot more test code.”

    Reply
René Pirringer says last year

You ask for tips about starting to do TDD with Swift. I have done a TDD workshop using Swift 4 month ago. At this workshop a simple Todo list app was created from scratch. As preparation I have implemented the app step by step and I have put the code on github:
https://github.com/openbakery/MyTodos

I have also added a tag for every step, so that it is possible to reproduce the progress.

With this example you can investigate how I do TDD in my projects using swift.

Reply
Matt says 11 months ago

How about just writing tests in Java & then using j2objc to bring this code into ObjC?

Too many languages & environments, not enough lifetime.

You’d end up writing some java versions of the objc apis…. but that is good software design, no? There is another tool, though it is paid, that’ll convert ObjC -> java that might speed this up.

Just an idea.

Reply
Add Your Reply