File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes test driven design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "test driven design" Watch "test driven design" New topic
Author

test driven design

kundan varma
Ranch Hand

Joined: Mar 08, 2004
Posts: 322
Hi All,
What is test driven design??? How can i make any project based on this design?
Thanks,
kundan


SCJP1.4,SCBCD,SCEA,CNA
Failures are practice shoots for success.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
There is a good summary at http://www.objectmentor.com/writeUps/TestDrivenDevelopment and an example at http://www.objectmentor.com/resources/articles/xpepisode.htm


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
kundan varma
Ranch Hand

Joined: Mar 08, 2004
Posts: 322
Do you really think XP programming should be so strictly followed or is possible in real life coding and design???
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
It's at least a good idea to try it for a while, in my experience.

I don't understand what you mean by "real life coding and design" - what in the example seems to conflict with reality to you?
kundan varma
Ranch Hand

Joined: Mar 08, 2004
Posts: 322
What i mean was that is an example rather than real life project
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Yes, they work in real life. Robert Martin proposes these three rules:


Over the years I have come to describe Test Driven Development in terms of three simple rules. They are:

1. You are not allowed to write any production code unless it is to make a failing unit test pass.

2. You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.

3. You are not allowed to write any more production code than is sufficient to pass the one failing unit test.

See more from his blog on the topic.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by kundan varma:
What i mean was that is an example rather than real life project


Well, when I work in real life, it often enough works very similarly to the example, yes.

I guess I still don't understand what your doubt is...
Jeff Langr
author
Ranch Hand

Joined: May 14, 2003
Posts: 762
Ahhh, I'm still proud of that Object Mentor writeup on TDD for its short and succinct nature. It makes things sound so deceptively easy. ;-)

As far as using TDD (test-driven development) on a "real" effort, shops all over the place are doing it all the time, some for extremely large applications. Sabre, for example, uses it for some pretty complex systems.

Most of us who've done TDD for some time won't go back to any other way of development. None of us would consider writing any sort of large system without the confidence, design guidance, and comprehensive documentation TDD gives you.

-Jeff-


Books: Agile Java, Modern C++ Programming with TDD, Essential Java Style, Agile in a Flash. Contributor, Clean Code.
Jeff Langr
author
Ranch Hand

Joined: May 14, 2003
Posts: 762
oh yeah, and you can do TDD and pretend that it never came out of XP. It works just fine as a development practice on its own.

-Jeff-
Jeff Langr
author
Ranch Hand

Joined: May 14, 2003
Posts: 762
If you want an example of a "real" system built using TDD, take a look at the source for the testing tool called Fitnesse.
kundan varma
Ranch Hand

Joined: Mar 08, 2004
Posts: 322
Thank you all for your inputs, ya now its clear to me and acceps that TDD is the right and proper way of doing a project

Thanks,
kundan
Michael Duffy
Ranch Hand

Joined: Oct 15, 2005
Posts: 163
The never-ending fight that I have with project managers is the time and effort required to develop and maintain a complete JUnit test suite. If you test every class and every method, you've roughly doubled the size of your code base and maintainence effort. That effort isn't free and without cost, and it takes an enlightened PM to realize what's in it for them. When they are rewarded on budget and schedule metrics, and not on-going quality or maintainence, it's a hard sell.

I try explaining that it's better to find defects as early as possible, and a complete JUnit suite will pay dividends later on when it comes time to refactor or add new features, but the argument often falls on deaf ears.

We did write JUnit tests on the last project that went to production - on time and no defects, but we were far from 100% code coverage. As deadlines loomed the JUnit tests were put aside.

I hope to do better next time, but it takes planning and foresight. Not everyone on the team is 100% behind it.


%
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
The problem is that without the tests, you don't know as well when the code really is *done" - that is, is actually working.

With other words, when you don't have tests, how can you say you are done when actually you have to expect to still spend a significant amount of time on debugging and bug fixing?
Hemant Agarwal
Ranch Hand

Joined: Nov 21, 2005
Posts: 138
Nice discussion
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: test driven design