The Tests are the Design

time to read 2 min | 254 words

I've found myself stuck trying to design a new UI for NHibernate Query Analyzer. The problem was that I was determained to use TDD to do it, and I just couldn't see how I can do it properly. Anything that I came up with was quite absurd in its complexity, both to test and to write. I tried several approached, and read quite a bit about MVC. But I still got to the point where I'd a displaying UI, and no clear distinction what goes into the View and what goes into the Controller (at least I managed to define what belong in the Model, that should count, doesn't it?).

Then I tried to do it in the Test First approach, with no previous design, I choose a simple goal, a user should be able to create a new project, and then just coded a story in code, and then I went to the unit tests and coded the tests for the functionality that I needed. Only then I wrote the code that actually did something beside testing.

Working this way, the final connecting of the code was very easily done. Now what I need is a simple set of forms which are databound to the objects that I'm displaying, and that should be be it. I've a lot more stories to write, and it should be interesting how I can manage to test "user run a query and get an object graph" story.