Quality Coding
Shares

TDD Sample App: 20 Topics that May Spill Out

Shares

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.

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.

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

TDD sample app: Marvel Browser!

A worked example can’t be hand-wavy; it needs to be something concrete. I asked you for concrete ideas, and some of you suggested the Marvel Comics API. It looks clean and straightforward, so it should work well for our TDD sample app. Besides, the dataset will be fun!

The Marvel Comics API provides a way to look up comic book characters, so that’ll be the main focus of the app. But let’s break that down further. Here are a few use cases that come from the way we use mobile apps:

  • User initiates search for Marvel characters, where the names of those characters match some given prefix. The results include character images and other information.
  • User requests next page of results.
  • User implicitly cancels current request by navigating away.

This small set of use cases is common to most networking apps. It’ll give us plenty to start with.

20 possible topics (TDD and otherwise)

Although we have only three use cases, working through them will lead us through many topics, such as:

  1. Project setup
  2. Managing app start-up
  3. Test organization
  4. Asynchronous networking
  5. Building requests
  6. Building objects from JSON responses
  7. Error handling
  8. Logging
  9. Canceling requests
  10. Clean architecture
  11. SOLID code
  12. Paged results
  13. View controllers
  14. Dependency injection
  15. Storyboards
  16. Collection views
  17. Displaying images
  18. Stronger static analysis
  19. Coupling, cohesion, and complexity
  20. Managing the class dependency graph

Despite the numbering, this isn’t an ordered list. Some of the topics are about applying TDD, while others are about design issues. What “test driven development” drives isn’t just code with tests. TDD also drives design. So even though I’m calling this a “TDD sample app,” design issues will weave in & out of the examples.

I may sometimes write something that looks like a digression. As I see it, anything that can help you work more efficiently is fair game. That’s why I wrote 6 Simple Power Tools for Better Git Use; it’s the first set of ideas that came up as I started the Marvel Browser project. But in general, expect a steady flow of TDD examples and related object-oriented design issues.

Subscribe to follow / Pass along to a friend

So get ready! Some ideas will be new to you, and you’ll be able use them immediately. Some techniques may raise questions. When that happens, please raise those questions, because with good discussions, we all win.

To make sure you don’t miss a single post in this series, please subscribe. You’ll receive new posts directly by email. Or if you have already subscribed, can you think of a friend or colleague who would benefit from this series? Then be sure to pass this article along to them.

Question: Which topics do you look forward to the most? You can leave a comment by clicking here.

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

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:

Leave a Comment:

11 comments
Add Your Reply