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

When I was a kid, programming was fun. But working in Silicon Valley, I saw poor code lead to fear, with real human costs. Searching for ways to make life better, I learned about Design Patterns, Refactoring, and Test Driven Development (TDD). Programming became fun again! I've now been doing TDD in Apple environments for 17 years. I'm committed to software crafting as a discipline, with the hope of raising us all to greater effectiveness and joy.

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

    Looking good.

    I need some design knowledge so I am looking forward to those discussions.

  • kenji21 says:

    Very nice program, looks to real apps we used to develop in my company, I’m impatient to read all this.

  • David C says:

    These are the topics I look forward to the most:
    Test organization
    Asynchronous networking
    Building requests
    Error handling
    Logging
    Canceling requests
    Clean architecture
    SOLID code
    Paged results
    Coupling, cohesion, and complexity
    Managing the class dependency graph

  • Hello Jon,
    I’d be really interesting on how you use storyboards with builders and dependency injection (if possible).
    I was yesterday discussing with @codermay about how to move our builder approach to storyboard, and I don’t think it’s possible.

    Also it will be very interesting to know how you choose between two technologies or approaches when the gains/loses are no quantifiable and clear (sometimes is just about feeling or preference than engineering? ).

    Thanks!

  • Jacob Davis Cherussery says:

    These are the topics I look forward to the most:

    Error Handling
    Clean architecture
    SOLID code

  • PrideChung says:

    Can’t wait to see the real code. Avengers, gear up!

    These are the topics I look forward to most:
    Error handling
    Clean architecture
    Dependency injection
    Coupling, cohesion, and complexity
    Managing the class dependency graph

  • matias elorriaga says:

    very good initiative! I’m really looking forward to.. thanks!

  • Really nice!! Thank you for doing this, it’s sure will help many of us.

  • Anand says:

    If possible, please cover also one of the libs or way to map REST service directly to Core Data (saving & fetching, updating etc) and also unit testing (TDD) on database.

  • Richard says:

    Hey Jon, I cannot find where you may have posted this case study. Very interested. Thanks!

  • >