Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I want to know how to prove TDD is best compared to code inspection in terms of time and cost.

share|improve this question

closed as not a real question by gnat, Kilian Foth, Steven A. Lowe, dietbuddha, ChrisF Feb 19 '13 at 8:44

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Hi. This isn't a question, so it's offtopic for this site. –  Andres F. Feb 19 '13 at 3:54
Run two projects at the same time, whichever one finishes first and costs less is better. (for that project). –  Craig T Feb 19 '13 at 3:58
This is not provable. The best you could hope for is an empirical answer based on the results of field trials of the respective approaches on "real" projects. (And you could easily disprove it. If you can find just one project in which TDD wasn't better ... you have proven that TDD isn't always better.) –  Stephen C Feb 20 '13 at 9:42

3 Answers 3

You won't be able to prove "TDD is best", because it isn't true.

It's not an either/or decision, they are orthogonal techniques and if you want your code to be any good, you probably should be thinking about doing both.

Note that:

  • TDD won't tell you that your junior developers are creating lots of confusing spaghetti code and turning your architecture into a big ball of mud. Only code inspection / peer review with experienced developers will do that.
  • Code review won't tell you that the code works for a wide range of possible inputs. Only comprehensive automated testing will do that.
share|improve this answer
is it possible to use code coverage tool to prove –  user81799 Feb 19 '13 at 6:37
For a general prove? Never ever. They may help to collect the metrics but they can't measure the costs of both methods and can't find software defects (which is another aspect for comparision). If they could find those, then coverage tools were much better than TDD and code inspection ;) –  Andreas_D Feb 19 '13 at 6:41
in terms of defect able to prove means then what i have to do? –  user81799 Feb 19 '13 at 7:18
in case we cant prove by changing one parameter to prove TDD is best –  user81799 Feb 19 '13 at 7:23

Just because you use TDD doesn't mean you code will pass a quick eyeball inspection.

TDD is a great methodology - it doesn't allow you to wander too far away from small, maintainable sections of code. However, it's no substitute for peer reviews or any other sort of review process. It also doesn't act as a saving grace from compliance tests (OWASP or anything to do with PID).

It's also the case that people can forget to "refactor" - which means they're not really doing TDD - but it happens. A code review/inspection will serve as a reminder or prodding to ensure that those refactorings get done - for any reason such as code style, unsafe checking, unsafe double-null checking, or auto-unboxing when not really desired.

share|improve this answer
actually i want to disprove this paper "comparing defect reduction benefits of code inspection and test driven development" just want to prove TDD is best in terms of time and cost.is it possible.please suggest somee ideas. –  user81799 Feb 19 '13 at 4:17
So have your company give it a try for a few cycles. The only way they'll be able to agree is if you have concrete evidence of it, and they'd have to have firsthand experience with it, too. –  Makoto Feb 19 '13 at 4:18
but i didn't get any evidence –  user81799 Feb 19 '13 at 4:35
Any related paper is there to get evidence for that? –  user81799 Feb 19 '13 at 4:53

Quality control is a well researched topic. Caper Jones has a paper that shows the effectiveness of the various Quality Control methods. There is a rough and ready rule, the longer a bug exists for, the more it will cost to fix (in terms of both time and final product quality). .... Quality control in order of value (ROI), most valuable first: Requirements inspection, design inspection, code inspection, TDD. (I have yet to see any science that disagrees with this order.)

The nice thing about TDD, is most programmers "get it", without having to do training. (Inspection tends to require a training course.)

share|improve this answer
which paper are you talking about? –  Louis Rhys Feb 19 '13 at 7:08
That is one IEEE paper "comparing defect reduction benefits of code inspection and test driven development" –  user81799 Feb 19 '13 at 7:22
"comparing defect reduction benefits of code inspection and test driven development" –  user81799 Feb 19 '13 at 7:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.