Book Review: Test Driven iOS Development with Swift by Dr. Dominik Hauser

When people first start to learn how to program it is always the flashy, forward facing aspects of development that most people gravitate too. It might be creating some sort of beautiful, dynamic interface, or writing complex algorithms that set your program apart from everyone else. But the reality is that a lot of the time spent programming is doing debugging, and making sure error handling is managed correctlyand writing unit tests. Those tasks are certainly less exciting, but also critical to making apps work well. The latter of those tasks, unit tests, is particularly important, and often ignored, which is where test driven development (TDD) comes into play. The shortest explanation of what TDD is would be that it is a paradigm for developing in which you write unit tests first, and then the necessary code to make those tests pass. With this development workflow you cannot ignore unit tests because without them your code cannot exist.

Test Driven iOS Development with Swift by Dr. Dominik Hauser (USD 31.99) is not for the faint of heart. You need to have a strong understanding of Swift and iOS development going into it. This definitely falls into the category of advanced level topics. It is also going to require a real investment of time. Three quarters of the book is a single tutorial that takes you through the process of TDD by creating a ToDo list app. If you are not going to commit to working through the whole book then I would suggest you simply skip getting the book. But, if you have a specific need to learn TDD, or have a strong suspicion this is going to be something you want to learn and implement in your own workflow, then by all means keep reading to see what this book is about.

What the book is about

Test Driven iOS Development with Swift starts by explaining some of the history behind TDD, how to get Xcode setup for unit tests, and some basic examples of unit tests and how to write code based on them. The first quarter of the book is easy enough to get your head around. But the following three quarters is where you dive head first into a tutorial that shows how to use TDD to create an app. This is where it gets really complex and, at times, hard to follow.

With TDD you are constantly repeating these steps: write the test, make it pass, and refactor. Because of this method of working it means you are continually going back and forth between reading a paragraph or two, typing and adding in code, then going back to the book. Because of this flow it often means progress through the book is incredibly slow. You could just read through the book without doing the tutorial in Xcode yourself, but the book is not structured in a way that this would make sense. Rather, many people will have to read through the book a second time as it is hard to take in everything being discussed when you are also focusing on writing the code as you follow along.

The writing can be a little challenging at times. This is a very technical book and the writing is not what you would call poetic. There were a few times were information seemed to be unnecessarily repeated, and some descriptions were not entirely clear. On the other hand the author does do a good job giving background information on specific concepts where needed. So although this is an advanced topic and not written for beginners, it does attempt to be accessible, though not always with the best success.

The layout in the E-Pub version, which is the one I read, is nothing special or memorable. There are colour images when screenshots are shown, though they do appear a little fuzzy on retina screens, but nothing that is terribly distracting. Code blocks are in black and white courier style font, which I understand why authors might choose, but still don’t care for in most cases.

Still related to the subject of layout one of the aspects of Test Driven iOS Development with Swift I found could really be improved is how it presents some of the tutorial steps. Often you would be shown a function, which you would type into your project, and then a few pages later be instructed to change some aspects of that code. It wasn’t always clear where those changes needed to be made within your own code, which had a tendency to slow your progress down. There is a way to address that, through the use of videos, and I will talk about that momentarily.

How effective was the book

TDD is not a subject that after reading a single book you are going to be off and running with. It is a fundamentally different way of doing development and requires dedication and practice, and will take a real commitment to get to a point where you can use it without really thinking about it. This book does make a strong attempt to show you how exactly it is used by going over its implementation in a single project, from start to finish. The book did teach me a lot about about TDD, and unit tests, and how to write code that is usually no more then one or two steps away from working perfectly. But it also did not leave me in a position where I could feel comfortable going out and start using it on my own either.

There are some aspects of this subject which don’t translate well into book form. The tutorial is an absolute must for learning the topic, but a screencast video would likely be a much more effective way of presenting this information. And although the tutorial was incredibly in depth, it was just one tutorial. Having even a second one, even if it went into a little less detail, since it would be a follow up, would really help make a lot of the concepts more concrete. I understand that authors have constraints in time and resources and even how their material can be distributed. Though add-ons, such as videos, are becoming more common, they are not always possible. But it is also about choosing the right medium to communicate an idea and in this instance videos really feel like a far better option.

For someone with a lot of programming experience, and a strong need to learn TDD, I could see this being an effective book teaching the subject. But from my own perspective, this is not a book that casual readers or even intermediate level programmers are going to pick up and be able to work through comfortably. Yes, I did learn a lot from it, but if the end goal is to teach someone enough to be able to start using TDD on their own, then the book was not effective in achieving this.

TL;DR

Test Driven iOS Development with Swift is a very interesting, but ultimately hard book to get through. If you are already at an advanced level when it comes to programming in Swift, and have experience with unit tests, then this book might work out for you. But for anyone who isn’t at that level this is going to be a really challenging to get through. If this book were also packaged with a series of screencasts that allowed you to watch TDD in action then this would make the subject a lot easier to understand. Screencast would also make it much more accessible to those who want to learn, but don’t have years or decades of experience under their belts.

The other challenge this book faces is that because TDD is a different paradigm for how you develop, there is not only a time investment in reading the book, but then integrating this way of working into your day to day development. For developers under tight schedules this is going to be a hard sell, and for team environments this may never get past a first discussion because unless everyone is on board, it just isn’t possible to implement. Even if you decide not to adopt TDD the book will at least offer a new perspective on development and perhaps illustrate the importance unit tests play. But unless you have a strong motivation to learn about TDD this is not going to be a book someone is going to pick up for some casual weekend reading.

As always you can find me on Twitter @third_beach if you have a question or comment. You can always leave a comment here on the site. I am always open to feedback and hearing what others think, or experiences they have had, with the books I review.

Leave a comment