Quality Coding

All posts by Jon Reid

Emoji: Baby Chick

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.

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.

Continue reading

Emoji: Horizontal Traffic Light

Static Analysis: Will It Free You from the Need for TDD?


There’s been a growing debate about static languages vs. dynamic languages. For me, writing my own reaction helped me discover that I was unfairly judging Swift based on C++.

In the midst of the debate, another interesting article popped up: Eric Elliot’s The Shocking Secret About Static Types. It points to a couple of studies. One study concludes that there is a lack of evidence that static typing reduces defect density. The other study concludes, “There is a small but significant relationship between language class and defects.”

Check out Eric’s fascinating conclusion:

When it comes to bug reduction, I think it's fair to say: Static types are overrated. But when it comes to other features, static types are still cool, and may still be worth using. Bottom line: You want to reduce bugs? Use TDD. You want useful cod intelligence tools? Use static types.

We’ve come full circle: a discussion about static types has again brought us back to TDD. Why?

Continue reading

Emoji: Female Factory Worker

Need Feedback Now? Quickly Hack a Spike Test


You’re building a new network call to a server. The thing that will actually use this call isn’t ready. But you’re anxious to see the call work in a full round-trip to the actual server. Basically, you want to know: does this part of the code work? How can you get the feedback you need?

Answer: Quickly hack together any way that works.

The agile workflow is to build, validate, and adjust course. Extreme Programming teaches us to use many feedback loops. And fast feedback is the primary benefit of TDD. …But TDD isn’t the only way I’ve gotten feedback on my Marvel Browser:

  • I did a spike solution to learn how to do request authentication for the Marvel Comics API.
  • Having TDD’d that authentication, I wrote an acceptance test to ensure that it works.

This time, I want to combine these two approaches. It’s a hybrid for which I don’t have a name. Maybe a “spike test”?

[This post is part of the series TDD Sample App: The Complete Collection …So Far]

Continue reading

Emoji: Man Facepalming

How a TDD Mistake Revealed an Error in My Design


My TDD has improved since I first started in 2001. But even today, I make mistakes. The trick is to learn to recognize TDD mistakes. Then, learn to “listen” to them: what is it trying to tell me about the design?

Follow along as I recount the latest steps in Marvel Browser, the iOS TDD sample app. Can you spot the errors before I point them out?

[This post is part of the series TDD Sample App: The Complete Collection …So Far]

Continue reading

Can TDD Be Simple? With Preparation, Yes


TDD doesn’t make anything happen automatically. You really need to level up on two other skills as you go: design, and unit testing. Doing so can shift TDD from being daunting to being simple.

Let’s look at how a change to unit testing empowers TDD.

Continue reading

Simpsons bully Nelson Muntz mocking,

Type Safety, 100% Coverage, and Robert Martin: Who’s Right?

Robert Martin creates strong impressions, with outlandish costumes and black-and-white statements. If you understand that this is his didactic style, you might appreciate his content. (Sadly, his black-and-white statements also extend to hurting people, especially women and minorities.) But people seem to enjoy jumping on statements rather than trying to grasp the whole.

I’m referring to the sentence: “You don’t need static type checking if you have 100% unit test coverage.”

This is one of the closing statements from a blog post, Type Wars. Various people jumped all over this, with much LOL.

Who’s right? Is Martin right? Are his detractors right?

Applying my faith to life, I find that “right and wrong” isn’t a helpful filter.

I want to start by trying to see the points of view of the detractors. But then I want to expand on Martin’s statement, from my point of view. Finally, what do I think this means for Swift?

Continue reading

Emoji: Wrench and Hammer

What Are Your Favorite Tools for Productive Programming?


I’m always on the lookout for new tools. Are you? Anything that might increase programmer productivity is worth a look.

You know that I’m a big AppCode fan. It saves huge amounts of time. And doing so within an IDE helps me stay “in the zone.”

I’ve shared about 6 Simple Power Tools for Better Git Use. Thanks to reader comments, I learned about Oh-My-Zsh for command-line, and SourceTree for GUI. AppCode also provides great Git support.

So I’d love to hear more from you. What are your favorite tools for productive programming? Share your tips in the comments below!

Emoji: Man and Woman Holding Hands

How to Make Your Own OCHamcrest Matcher for Powerful Asserts


OCHamcrest matchers are predicates on steroids:

  • You can combine them to create expressive assertions.
  • They describe mismatches in detail, reducing the need to debug.

But OCHamcrest isn’t just a library of powerful matchers. It’s a framework for creating your own.

By creating a custom matcher, you create a small Domain-Specific Language. This will make your unit tests easier to write, easier to read, and self-diagnosing!

In this post, we’ll walk through the 9 steps of creating a custom OCHamcrest matcher.

[This post is part of the series TDD Sample App: The Complete Collection …So Far]

Continue reading

AppCode vs. Xcode Unit Testing Battle


AppCode vs. Xcode: Which is easier to use for unit testing? Which gives better feedback?

I’ve written about the big improvements to OCMockito’s error reporting. But when I ran the tests, I saw striking differences between the two IDEs.

Continue reading

Swift custom XCTest file template

Would You Like an Improved Swift Unit Testing Template?


Back in Xcode 4 days, Apple’s file template for Objective-C unit tests was awkward and bloated. So I made my own.

Fast-forward several years. I’m coding in Swift now. The first thing I want is unit tests — let’s create a new test suite.

Why am I not surprised that Apple’s template for Swift unit tests is filled with cruft?

Fine. I made my own.

Continue reading

1 3 4 5 6 7 12