Design in the Red step

When you’ve got an IDE it’s very convenient to create classes and method directly from the test case.

Learning Objectives

Session Outline

Connect - ways to create a class

Put up the IDE on the big screen, with an empty project and empty test case open. Ask “I’d like to create a new class, called LiftButton. What should I do? Please navigate me”. Hopefully someone will ask you to use the new class wizard or similar. Create the class as they instruct. Ask again - is there any other way to create a class? Hopefully someone eventually will tell you to write new LiftButton() (or similar) in the test case. Bingo. Make sure they see how you use the tool to summon the new class into existence from the test.

(Of course if no-one suggests this you show them anyway)

Concept: Design in TDD - the red step

The test is the first time you use the class or method. Before you use the tool to summon it into existance, you can examine how easy it is to use your design. It’s the cheapest possible moment to change your design decisions.

Do: Lift Button

Practice writing the tests first before creating the classes and functions they describe. The Lift Button Kata might be a good one.

Before you split into pairs to work on the kata, spend a few minutes in the whole group coming up with a test list. Something like:

When they are doing the kata, try to stop them from creating any functionality without first creating a test case. Have them practice using things in the test before they exist in the production code.

Reflect: keyboard shortcuts

Which keyboard shortcuts did we use to create things? Make a note so you remember them.