I have seen many articles on why Test Driven Development is good and that it reduces development time and so on. But after searching through a lot of forums, I am still yet to get a concrete advantage of TDD. I am not saying testing is a bad thing, but my point is what is the harm if I write my unit test after I write my source code rather than vice-versa as TDD proposes. And both the test cases do act like regression tests once it is complete. I also experienced a lot of problems while trying to follow TDD in a legacy code.I guess nowadays most of the code is legacy code where we have to modify code without pre-existing tests. Also is TDD limited to unit tests only or even system level and integration tests. I am just not able to imagine how we can do integration tests without writing source code.
I won't say that TDD shorten the development time. It could even be longer. But TDD leads to "clean code that works". The software grows at the same time as the unit tests, not one after the other, and thus is tested as soon as it it written. This gives confidence to the developer as well as a good idea of "where he stands" because he knows that what he has done so far is "done done".
Also writing the unit tests after the fact, can be hard. The author "Working effectively with legacy code" (a very good resource BTW) even says that code written without unit tests indeed is legacy code.
Also is TDD limited to unit tests only or even system level and integration tests. I am just not able to imagine how we can do integration tests without writing source code.
TDD is a development technique, it's not intended to replace other kind of testing.
One can however write integration tests before the code to be tested exists. This allows asking oneself how the code that will be produced can be tested.