3

Is TDD good approach for small and short projects done by small teams up to 4 people ? Is that really a profitable effort ?

What about Unit Testing ? TDD implies Unit Testing but no conversely. Wouldn't be Unit Testing sufficient, done from time to time during the project development life cycle, until reasonable code coverage ?

jwaliszko
  • 16,942
  • 22
  • 92
  • 158
  • 2
    Look at this link about TDD vs Unit testing: http://stackoverflow.com/questions/1742323/tdd-vs-unit-testing – dexametason Mar 30 '12 at 08:51
  • TDD is only approach to design, it may result in good design, but other approach may too. Unit Testing is a way to keep your codes consistent and easy to modify, it's necessary. – Kirin Yao Mar 30 '12 at 09:04
  • TDD should drive your design decisions, when unit testing on its own will validate logic of individual components. –  Apr 02 '12 at 09:36
  • Check s&s - spike-and-stabilize approach from this blog: http://simon-says-architecture.com/2012/06/27/if-you-are-not-doing-tdd/ – jwaliszko Sep 10 '12 at 13:38

5 Answers5

2

For me, it doesn't boil down to whether the project is small or short. TDD, done correctly, is about being able to quickly run a set of tests that provide full confidence in the code. There also has been a lot written about TDD helping to drive out the appropriate design for projects as well.

So, you could argue that TDD is best on small and short projects because you end up only writing the code that you need to make the tests pass and nothing else. Therefore, keeping the cost down. Then, there is the added benefit of having confidence in the tests and code when you make changes later.

The next small point I would make is that a lot of projects start small and short. These interim solutions have a way of becoming strategic platforms for development (if successful).

Davin Tryon
  • 66,517
  • 15
  • 143
  • 132
  • +1. Completely agree with TDD being all about the confidence that, at least programatically, the code does what you expect it to. Good point about the projects starting small! So many projects I've worked on have started small and been an absolute nightmare to fix or extend, due to bugs and terrible architecture. TDD helps on both fronts. – Alexander R Mar 30 '12 at 09:07
1

Recently I've read nice blog post from Szymon Pobiega, titled If you are not doing TDD…. I really encourage to take a look on this. It's because I'm a bit skeptical about TDD and placing it into great habits of development life cycle, as an ultimate solution for your projects safety, apart from the nature of the project. I like this fragment:

TDD is most useful when you have absolutely no idea about the shape of the code. In such case you better not hack the code as fast as you can. Rather then make one small step at a time, each time validating the outcome. Ideally, do it in a pair. Each step you make allows you to discover more tests that need to be written. I love the analogy Dan used in his presentation: it’s just like swimming versus walking in 1.50 meter deep pool. You can walk all the way through ensuring every time one of you feet is on the ground or you can just swim which is more risky (no contact with ground) but makes you move a lot faster. TDD is like walking.

He is referencing to Dan North session from NDC 2012.

jwaliszko
  • 16,942
  • 22
  • 92
  • 158
0

The answer is YES! And for the following reason. Picture yourself the following scenario. You and your project team have created a great application and decide to put it in production. After a while a user comes to you saying: Hey guys I found a bug in your application can you fix it please? Of course you say yes fix the bug and the user is happy. Only after a while he comes back saying, great that you fixed the problem but now something that did work doesn't anymore can you repair it?

If you had used TDD and had made unit tests for the application the scenario wouldn't be like this. This is because you have tests made for your entire application. After solving a bug, you simply run the unit tests again to see if your "fix" din't break any other things in your application.

This answer is more aimed at the use of unit tests. The following is abbout TDD itself.

What TDD makes you as an individual do is think about what am I going to code in the following (object, class, function and so on). Also what are the edges of my code what if/else statements do I need what do I need to check for. If you are by yourself or in a project team of 20 people, this doesn't really matter. The thing with TDD is the thinking process of you not the other people in your project.

Rick Hoving
  • 3,585
  • 3
  • 29
  • 49
0

If you are doing UnitTesting its only a small step to adopt TDD. But you will benefit much more from it.

Just one example: TDD defines that you implement your tests first. This implies that you think about the goal that you want to achieve before you start to implement. This leads to better code.

magomi
  • 6,599
  • 5
  • 31
  • 38
0

TDD and Unit Testing are not alternatives to each other. In every project you should test your code, this is where you do Unit Testing and Integration and System Testing.

TDD is however, a development model. Like Waterfall and other development methods, TDD is a method too. In TDD you have some basic requirements and you write unit tests to ensure that the requirements are implemented and working. But when you are writing unit tests you realize that in order to achieve the major requirements, you need to implement more functions and classes. So unit tests in this context makes other requirements clearer.

Suppose that you need to write an application that prints the name of the computer the application is running on. First you write a unit test:

[Test]
public void ProducedMessage_IsCorrect()
{
    AreEqual(BusinessLibrary.ProduceMessage(), System.Environment.MachineName);
}

and then you realize you need to implement the ProduceMessage function. You implement it as simple as it gets so that the unit test passes. You write the method like this:

public string ProduceMessage()
{
    return "MyComputer";
}

Then you run the test and it passes. After that you submit your code and other members of the team gets the code. When they run the test the test fails because you hardcoded the name of your computer in the code.

So some wise member of your team changes the code to the correct form and you keep going.

It is all about choosing developers who have TDD experience. At least some of them should be experienced TDD developers I think.

Mert Akcakaya
  • 3,109
  • 2
  • 31
  • 42