.st0{fill:#FFFFFF;}

TDD Sample App: 20 Topics that May Spill Out 

 November 17, 2014

by Jon Reid

11 COMMENTS

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 clear 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 clear 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. Clear 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.

What “test-driven development” drives isn’t just code with tests. TDD also drives design.

Click to Tweet

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]

Jon Reid

About the author

Programming was fun when I was a kid. But working in Silicon Valley, I saw poor code lead to fear, with real human costs. Looking for ways to make my life better, I learned about Extreme Programming, including unit testing, test-driven development (TDD), and refactoring. Programming became fun again! I've now been doing TDD in Apple environments for 20 years. I'm committed to software crafting as a discipline, hoping we can all reach greater effectiveness and joy. Now a coach with Industrial Logic!

  • 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!

  • 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

  • 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.

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
    >