Which comes first? Class, use case diagrams or dive into code using TDD?

101 Views Asked by At

Which comes first? Doing proper oo analysis and design and create uml digrams then TDD cycle or just dive into code using TDD cycle?

1

There are 1 best solutions below

6
Mark Seemann On

The short answer is: whatever works best in the situation.

Slightly longer: TDD typically works best as a feedback mechanism. This doesn't mean that thinking ahead isn't allowed. Quite the contrary, thinking ahead is fine, but what's at least as important is to reflect on how the plans unfold.

As Eisenhower put it:

Plans are worthless, but planning is everything

In programming, most people's experience is that Big Design Up-Front rarely works, because compilers and interpreters are much more rigid and literal than you can imagine when planning.

Or, as Jack Reeves expressed it in the 1992 essay What Is Software Design?, the code is the design. You can't really design the code before you write it.

TDD gives you feedback about your design ideas as you go. Is this API easy to use? Does the implementation behave predictably?

You'll often find that what initially sounded like a good idea turns out to work poorly in practice. Whenever that happens, you use that feedback to adjust how to progress.