It’s one thing to say, “Do test driven development.” But practicing TDD requires a set of tricks — you need techniques to enable test driven development in your particular environment. It’s these techniques which I hope to pass on to you through a case study of building an iOS TDD sample app.

The TDD sample app will yield treasures of how-to examples

Treasure Chest” by Tom Garnett, used under CC BY 2.0

I’ve accumulated a treasure chest of TDD ideas over the years. These ideas are often not my own, but are other people’s ideas which I collect and curate. Some are about object-oriented design. Some are about working in Xcode and Objective-C. And some are particular to iOS development. I’ve collected many, and continue to gather new ones.

I’m building this TDD sample app so that you and I can browse through this treasure chest together. You may have tried test driven development and given up on it. Or maybe you’re still trying, but finding it frustratingly slow. The ideas we will explore together will help you break through to make headway in your TDD journey, so that you can experience the freedom and ease that comes from automated testing and clean code. Continue Reading…

6 Simple Git Power Tools

November 10, 2014 — 6 Comments

What’s a technical skill that will increase your effectiveness, but isn’t programming? How about: being efficient your source control system’s command-line interface? Even though I’ve used Git for a while, there are some things I’ve picked only recently that have made me more efficient.

table saw

saw” by Shannon Kokosa, used under CC BY-NC-ND 2.0

Did you ever have a time when you were using a hammer, slowly driving in one nail at a time? Then along comes someone with a nail gun and BAM BAM BAM, they’re done! …That’s what comes with using a more powerful tool. We use source control systems every day, yet many of us slowly click on things in a graphical UI, or slowly type out commands in their entirety.

The more you equip yourself with good tools and learn to use them well, the better you’ll be able to stay “in the flow” of development. For example, time spent learning keyboard shortcuts for Xcode quickly pays off. In the same way, the better you can use Git (or whatever you use for source control), the more it gets out of your way, letting you concentrate on the actual coding.

So I want to show you 5 6 simple things you can use to improve your Git workflow — a set of Git power tools. These tools generally involve one-time setup (except for one that is a fun, game-like tutorial). Put these tools to use, and you’ll find you can get more done, more quickly. Continue Reading…

The results of my reader survey are in. The #1 request? Case studies of unit testing, with more complex examples. And that got me thinking about the next major direction to take this blog.

When I was first learning Test Driven Development, I didn’t really have any examples to look at. All I had were descriptions of TDD. I stubbornly believed that these descriptions showed a more effective way of programming, so I fought my way there through the School of Hard Knocks.

But you shouldn’t have to do the same. Continue Reading…

I want to make my blog better and more relevant to your needs and interests. To do that, I need to know more about YOU. As a result, I have created my first-ever Reader Survey.

2014-survey

Would you please take a few minutes to fill out the survey? By doing so, you will ultimately be helping yourself. Why? Because you will be helping me make my content even more helpful and relevant to you.

Your input is important to me. The survey is easy to fill out. It’s completely anonymous. And it will only take five minutes of your time.

Thanks in advance for your help.

objc.io is a monthly online magazine, with an editorial team. Each issue focuses on a particular subject, and Issue #15 is about Testing. I’m honored to be a contributor with my article “Dependency Injection”.

objc.io #15

Books

My article refers to two books I highly recommend:

  • Dependency Injection in .NET by Mark Seemann. This book is marvelous, and I need to study it more. (If you’re wondering why an Objective-C programmer is recommending a book with “.NET” in the title, you need to get out more. Learn what’s going on in other languages, and the smart folks who work in them.)
  • Working Effectively with Legacy Code by Michael Feathers. This now-classic text was instrumental to me when I first got started writing unit tests, helping me break through many conceptual barriers. Feathers boldly defines legacy code as “code without tests.”

Question: Do you have any comments about my Dependency Injection article, or any of the other Testing issue articles? Leave a comment below.

AppCode is an alternative IDE for Objective-C development. When it comes to test driven development, it’s superior to Xcode. But that’s not all. Check out the “inside-out” coding style it makes possible. In general, AppCode lets me focus more quickly on semantics and less on fiddling with source code.

Links:

Question: What other AppCode tricks do you like? Leave a comment below.

The Xcode 5.1 update proved to be more exciting than I anticipated. And I mean “exciting” in the sense of “breaking the tools I use.” xctool stopped working, and so did my code coverage scripts.

XcodeCoverage - code coverage for Xcode

Hole” by Bart Everson, used under CC BY 2.0 / Cropped

(Lesson learned: Always download the developer preview and give it a try, before running Software Update…)

Facebook updated xctool. And I’m happy to say that XcodeCoverage now works with Xcode 5.1! Thanks to my coworker Mike Maietta for figuring out how to create a wrapper around the new gcov so that it continues to work with lcov.

Your coverage numbers may change slightly as you use Xcode 5.1 — but not much. And we don’t need the __gcov_flush() workaround anymore. Hurrah! Continue Reading…

For my European readers: I have two speaking engagements coming up in January 2014. The first is with Mobile Central Europe in Warsaw on January 11. I’m honored to be part of this brand new developer’s conference! Here’s the cool conference trailer:

Then after an eBay iOS Developer Meeting in Berlin on January 13 (for eBay Inc. employees only), I’ll be speaking at eBay Tech Talk in Berlin on January 14 (open to the public).

I hope to meet some of you soon!

September Update: I capped things off with iOSDevUK and NSSpain.

Update: Apple took this to heart, and fixed things in Xcode 5.1.

Bug or feature? “You have to call __gcov_flush() to collect coverage data with the iOS simulator.” According to Apple, this is a feature. But not if you actually want to measure your code coverage.

Code coverage ERROR: no .gcda files found

But it worked on Xcode 4 / iOS 6…

Code coverage… oy vey! Back in the days of running on iOS 6 using Xcode 4, measuring code coverage for unit tests was fairly straightforward. A set of coverage scripts I published made it easier still.

Then along came iOS 7 and Xcode 5. Coverage still worked if you continued to run on iOS 6. But on iOS 7, you’d get “ERROR: no .gcda files found” indicating that coverage data wasn’t being captured. “Well, maybe I need to switch from SenTestingKit to Apple’s new XCTest framework.” Nope, that didn’t help. Continue Reading…

Dot notation is okay, after all.

There, I said it.

I’ve been a staunch opponent of dot notation. I saw it as obscuring messaging, and encouraging programmers to violate the Law of Demeter through chained dots. I went so far as to characterize dot notation as an Objective-C code smell.

So it may surprise you to learn that I’ve recently adopted dot notation in my code! Here’s how it happened…  Continue Reading…