Global Day of Coderetreat: Saturday November 15th, 2014Finished! Thanks for an awesome day.

TDD as if you meant it

Facilitating

Learning Goals

  • TDD discipline - this is a great activity to practice and re-enforce the Red-Green-Refactor cycle.
  • Tool Expansion - provides participants with a great technique for getting past "coders block" or for navigating through some tricky section of code.

Description

TDD as if you meant it is an advanced TDD exercise conceived of and proposed by Keith Braithwaite. In addition to coderetreat, various flavors of the exercise has been used at a variety of conferences and workshops.

The rules for TDD as if you meant it are:

  1. Write exactly one new test. It should be the smallest test which seems to point in the direction of a solution
  2. Run the test to make sure it fails
  3. Make the test from (1) pass by writing the least amount of implementation code you can IN THE TEST METHOD.
  4. Refactor to remove duplication or otherwise as required to improve the design. Be strict about the refactorings. Only introduce new abstractions (methods, classes, etc) when they will help to improve the design of the code. Specifically:
    1. ONLY Extract a new method if there is sufficient code duplication in the test methods. When extracting a method, initially extract it to the test class (don't create a new class yet).
    2. ONLY create a new class when a clear grouping of methods emerges and when the test class starts to feel crowded or too large.
  5. Repeat the process by writing another test (go back to step #1).

When to use

This is a great activity to use with a group who is already familiar with and is experienced with TDD. It is best introduced in the 3rd or 4th session of the day.

When NOT to use

Don't attempt TDD as if you meant it with a group who is not already familiar and comfortable with TDD. Instead, introduce some more basic TDD exercises (such as TDD Ping-pong).

Notes

When facilitating TDD as if you meant it, make sure you help pairs follow the steps. Asking questions is usually the best way to do this:

You: Why did you create that class?

Participant: I thought we needed it.

You: Why? Did one of the tests "drive" you to create it?

Participant: Hmm....

You: It looks to me like you might be taking too big of a step by creating the class. I suggest deleting the class and trying again.

It may also help to provide a brief demonstration of TDD as if you meant it before asking people to do it.

During the retrospective, help guide the discussion to reveal the primary learning objectives.

Further Reading

Back to the Activity Catalog

© 2014   Created by corey haines.

Badges  |  Report an Issue  |  Terms of Service