TDD-supporting (DDD Motivation 5)

Quite a few have tried, and failed with, TDD. Pretty often I believe they have tried to use TDD for an old application structured with Transaction Scripts together with an Anemic Domain Model and quite often every test will touch the database. TDD just doesn't work well in such a situation before you have taken pretty big steps to make the whole situation more test-friendly.

On the other hand, if TDD is used together with an application that has been structured according to DDD, I find the combination is very strong and you don't have to fight to make it work. (Sure, it still requires a lot of work and attention over time, but it's much more harmonious.)

I have quite often been asked whether you should choose DDD or TDD? To me, that's obviously a question that I want to answer with "both". When I have a first sketch of my model, I try it out with TDD. It's like thinking about the model from DDD as a clay model, and the tests of TDD are like hands working the clay.