views:

189

answers:

3

I have been learning about TDD and BDD and using this as much as I can at work but in an environment that really isn't agile.

I want to try it out properly on a pet project at home. So, going with the agile approach, and the principle of having working software, what should I write first? Should I create some forms first (this will be WPF / WinForms), linked to some dummy model? Or should I work ground-up. Any advice would be great!

EDIT

I know that I will be writing tests first. The question is at a higher level. Should I aim to put a working model and business layer together first or start with a form and a dummy model.

+3  A: 

I usually start with the feature and area that is most important. Take a look at this SO answer.

Mark Seemann
+1  A: 

If you want to do TDD/BDD you do start with tests.

In my humble opinion it is always good to start with model tests unless they are totally based on framework's functionality.

As for checking Controller/View part I prefer to have 'blackbox' tests which check if i get response I expect from an http request (for web applications). It allows to remove brittleness from the tests.

Even if I do full TDD test I often throw tests away if they are about nitty gritty parts of implementation, because otherwise very when refactor implementation at the end user experience is the same, so my application works fine, but I am spending hours fixing the tests. I don't to train myself to avoid refactoring just because I know the pain it would give by redoing a large body of testing code.

I would advice to test only things that really matter to you and ignore the rest till it bites.

When I do get a bug from something I was ignoring, I do write a test to document the bug even it it is about low level implementation.

dimus
+8  A: 

You are looking at it from a wrong perspective.

You are separating the application into components horizontally - UI component, backend component and so on.

Instead, you should look at it vertically - what are the different features - it could be login/logout, display list of users, display some other data and so on. Sort those slices into a priority order - which one needs to be done first, which needs to be done second and so on.

Then you concentrate on the most important slice until it works, whatever it takes - if it needs UI you add UI, if it needs backend logic you add backend logic and so on. Only after it is finished and fully working you go back to your list of slices, reevalute them, select the most important one again and concentrate on it.

Repeat until you are done.

This is basically what always working software means.

It allows you to stop at any point and say - this is good enough, and ship it.

If you work horizontally you will not have anything working until you finish all the work.

Gregory Mostizky
iterative development...
pjp