Not A Task, But An Approach 46

Posted by tottinger Fri, 03 Aug 2007 03:14:00 GMT

Transitions are tough. It seems that lately I’ve been getting a lot of contact from frustrated people who don’t really have a good handle on the “drive” part of Test Driven Development. A question heard frequently is: “I’ve almost completed the coding, can you help me write the TDD?”

It seems like Test Driven Development is taken backward, that the developers are driven to write tests. The practitioner winces, realizing that he again faces The Great Misunderstanding of TDD.

TDD stands for Test-Driven Development, which is not as clear as TFD (Test-First Development). If the consultant would strive to always say the word “first” in association with testing, most people would more surely grasp the idea. In fact, I’ve begun an experiment in which I will not say the word “test” without the word “first” in close approximation. I’ll let you know how that works out for me.

If the tests are providing nothing more than reassurance on the tail end of a coding phase, then the tests aren’t driving the development. They are like riders instead of drivers. Test-Ridden Development (TRD)[1] would be a better term for such a plan. Even though it is better to have those tail-end tests than to have no automated testing, it misses the point and could not be reasonably be called TDD.

An old mantra for TDD and BDD is “it’s not about testing”. The term BDD was invented largely to get the idea of “testing” out of the way. People tend to associate “test” as a release-preparation activity rather than an active approach to programming. BDD alleviates some of that cognitive dissonance.

In TDD, tests come first. Each unit test is written as it is needed by the programmer. Tests are just-in-time and are active in shaping the code. Acceptance Tests likewise tend to precede programming by some short span of time. [2]

Through months of repetition I have developed the mantra:
TDD isn’t a task. It is not something you do. It is an approach. It is how you write your programs.

I wonder if we shouldn’t resurrect the term Test-First Programming or Test-First Development for simple evocative power. Admittedly there are some who would see that as a phase ordering, but maybe enough people would get the right idea.

Brett Schuchert(with some trivial aid from your humble blogger) has worked up an acronym to help socialize the basic concepts which are somehow being lost in translation to the corporate workplace.

The teaser: Fast, Isolated, Repeatable, Self-validating, and Timely.

As a reader of this blog, you are probably very familiar with all of the terminology and concepts behind TDD. I beg of you, socialize the idea that testing comes first and drives the shape of the code. If we can just get this one simple idea spread into programming dens across our small spheres of influence, then we will have won a very great victory over Test-Ridden Development.

“And there was much rejoicing.”

1 Jeff Langr will refer to this TRD concept as “Test-After-Development”, which he follows with a chuckle and a twinkle, “which is a TAD too late.”

2 Of course, one still needs QC testing as well, however TDD is about driving development, not testing its quality post-facto.

Comments

Leave a response

  1. Avatar
    Sadek Drobi about 4 hours later:

    I agree with most of what you said, but not completely on ” drives the shape of the code.” I guess that this is confusiong, and needs a bit of clarification… see: It is NOT a test driven design!

  2. Avatar
    Tim about 9 hours later:

    I think you are right. I think I can do better.

    Clearly I am trying to say in that one throwaway line that test-first will change how we make decisions about our code (which patterns we’ll use or avoid, how much the code exposes state, how granular we make our functions, how much we rely directly on other objects, etc). In short all the things from my earlier posting and more.

    But that’s not what I said, and what I said can certainly seem an overstatement. I will make revisions.

  3. Avatar
    Jeff L. 3 days later:

    “A chuckle and a twinkle?” I guess I’m Santa Claus.

  4. Avatar
    Bill 3 days later:

    Ok, It’s Monday and I’m running a bit slow, what is BDD? Note Google wasn’t much help offering up:

    Behaviour-Driven Development

    Business-driven Development

    Backup Driven Development

    to name a few.

  5. Avatar
    Tim 4 days later:

    BDD is “Behavior Driven Design”, and is a further development of TDD. If you look at RSpec, you will see the current state of development of BDD. David Chelimsky and Dave Astels seem to have the lead on this.

  6. Avatar
    Anand 4 days later:

    See, as i understtod, TDD helps developer understanding requirements before coming up with code, and because they are going to write Unit test cases, they will certainly analyze each and every piece of requirement before writing a single line of code. But can you telle me, how it affectes our design, like which design pattern, and granularity of code?An example may be of more help.

  7. Avatar
    Tim 4 days later:

    TDD helps developers understand requirements (or at least correct misunderstandings early).

    I don’t know why you think that they analyze all requirements before writing any code.

    My experience is that one may look over the requirements (AKA “Acceptance Tests”) in small sets, but often doesn’t do a lot of “long range analysis”. Frequently the developer knows quite a bit because he has participated in the planning sessions and has helped estimate the story, but sometimes the AT is enough. Then there is the TDD three-step dance of one little test, one little change, one burst of refactoring.

    As to how it changes the shape of your code, this is lightly touched upon in an earlier referenced post. Generally, though, you will write the code intentionally to be (unit) testable. from the very start. That implies a lot of things.

  8. Avatar
    vabhav jain 4 days later:

    I am 100% agree but the follow the apporach you need to work on task

  9. Avatar
    Tim 4 days later:

    vabhav: certainly. You can’t drive the code without working on the code.

    Test-last development won’t have the same effect, and rather will force you to spend a lot of time and effort writing runnable tests, rather than writing testable code.

  10. Avatar
    Dean Wampler 6 days later:

    Just a bit more about Behavior-Driven Development (BDD); Dan North coined the phrase. Here is his article introducing BDD. There are now rbehave and jbehave tools for driving development at the requirements/story level, while rspec is focused more on the “unit” level.

  11. Avatar
    Nathan Henkel 18 days later:

    One problem I have with using the term “Test-First Development” is that I think it loses information compared to the term “Test-Driven Development”. The first simply suggests to me that I write tests before code (which is good), the second suggests that I write tests before code AND allow my tests to drive the design of my code, so I’m doing the “simplest thing” that will pass my tests.

    With test-first development, you might write some tests, and then write the code you “know” you’ll need (because you’re being driven by a preconceived design, or intuition, or cast bones), which happens to DO more than your tests actually verify. Now you have untested functionality. True TDD tells you to write the simplest code that will pass your tests, write new tests to demonstrate the inadequacies of that code, rewrite or add to the code to pass those tests and so on until you can’t think of any more useful tests. The tests are driving your coding, so, theoretically, you won’t have any untested functionality, and practically you’ll have very little.

    I do get the problem of making sure people understand that the tests have to come FIRST—how can they drive when they’re sitting in a trailer hitched to the back? On the other hand, putting them in the passenger seat or strapping them to the hood isn’t quite right either. Maybe not abbreviating is the answer, or perhaps emphasis: “test DRIVEN development”...

  12. Avatar
    Susan 10 months later:

    Im newbie here, thank you all!

  13. Avatar
    gucci louis vuitton shoes over 2 years later:

    Welcome to Freshstyleshop, the hottest urban clothing site on the net! We offer great products from Gucci sneakers, prada sneakers, LV shoes, True Religion Jeans and many more! Our selection of products are always increasing for the fact that we have new items added weekly to our selection. All products on our site are already marked down 40-60% off retail price. Freshstyleshop also backs all its orders with a 110% satisfaction guarantee, making sure that our customers are left satisfied with the hottest products on the net.

  14. Avatar
    gucci mens over 3 years later:

    Well , the view of the passage is discount gucci jeans totally correct ,your details is really reasonable and gucci belt for men you guy give us valuable gucci mens informative post, I totally agree the standpoint classic gucci wallets of upstairs. discount gucci hoodies I often surfing on this forum when I m free and I find there are so much good information we can learn in this forum!

  15. Avatar
    oxpdffr over 3 years later:

    CHM en PDF Convertisseur est un logiciel qui convertit des fichiers CHM (Compiled HTML Help Files) en format PDF avec le titre, le temps, la table des matières, en-tête, pied de page, numéro de page, etc. CHM en PDF Convertisseur possède encore plusieurs fonctions, par exemple :ajouter des filigranes, adjuster la résolution ou la taille du fichier, protéger les documents PDF par mot de passe, etc. Télécharger gratuitement CHM en PDF Convertisseur et expérimenter ce logiciel.

  16. Avatar
    iPhone to Mac Transfer over 3 years later:

    The software you can trust to export iPhone music, video and more to Mac.

  17. Avatar
    hair extensions suppliers over 3 years later:

    She would like something long and curly for herself and some kind of updo for the bridesmaids. Please post some pictures or links of styles.

  18. Avatar
    hair extensions manufacturers over 3 years later:

    nice articals

  19. Avatar
    hair manufacturers over 3 years later:

    actually like some just for goin out too.some are really nice for goin out.

  20. Avatar
    human hair manufacturers over 3 years later:

    Thank you very much. Those are great!

  21. Avatar
    Tenant Screening over 4 years later:

    True TDD tells you to write the simplest code that will pass your tests, write new tests to demonstrate the inadequacies of that code, rewrite or add to the code to pass those tests and so on until you can’t think of any more useful tests.

  22. Avatar
    cheap polo hoodies over 4 years later:

    cheap polo hoodies

    clothing for men

  23. Avatar
    damper over 4 years later:

    Our company is engaged in the professional manufacturer of damper, air cylinder, oil cylinder, and hydraulic station. The company has many year’s production experience and strong technical power.

  24. Avatar
    okey oyunu oyna over 4 years later:

    very good :)

    internette görüntülü olarak okey oyunu oyna, gerçek kisilerle tanis, turnuva heyecanini yasa.

  25. Avatar
    coach purses over 4 years later:

    Mr Coates coach purses is the longest U.S. market popular with one of the most successful leather brand. Mr Coates coach purses store represents the most admirable American fashion innovative style and traditional skills . Mr Coates coach bags have durable quality and exquisite technology, Conspicuous Coach Heels in the female consumers have good reputation. Welcome to our shop Elegant Coach Purses

  26. Avatar
    deadbeat millionaire over 4 years later:

    True TDD tells you to write the simplest code that will pass your tests, write new tests to demonstrate the inadequacies of that code, rewrite or add to the code to pass those tests and so on until you can’t think of any more useful tests.

  27. Avatar
    ????? ?????? over 4 years later:

    ?

  28. Avatar
    ????? ?????? over 4 years later:

    ?

  29. Avatar
    ????? ?????? over 4 years later:

    ???

  30. Avatar
    ????? ?????? over 4 years later:

    ???

  31. Avatar
    ????? ?????? over 4 years later:

    ??? ????

  32. Avatar
    ????? ?????? over 4 years later:

    ??? ????

  33. Avatar
    ????? ?????? over 4 years later:

    ??? ????

  34. Avatar
    ????? ?????? over 4 years later:

    ? ????

  35. Avatar
    ????? ?????? over 4 years later:

    ??? ????

  36. Avatar
    Bowtrol over 4 years later:

    it needs a bokmark so i can come back to it later ,nice stuff

  37. Avatar
    ralph lauren shirts over 4 years later:

    Obviously, when blunders like this arise color providers have practically nothing to eliminate. Each time persons choose decorate colors they are unsatisfied with, the color business won’t have to refund the customers’ capital. The truth is, no paint spots brand name inside state will allow you

  38. Avatar
    Red Wing Shoes Sale over 4 years later:

    Red Wing Work Boots—Highest quality Work Boots You Can Get Millions have enjoyed superior quality craftsmanship of Newest Red Wing Footwear. As you pick up a pair of these tough boots, you get Red Wing Suede Work Boots from a organization who cares about their work and who has been making Newest Red Wing Fur shoes for more than one hundred years. Realize now why they are considered by many the perfect work boots you are able to get. If you ever rely upon the saying you get what you pay for, you’ll be proud to purchase a pair of Red Wings Crazy Horse Shoe. These work boots are regarded for high quality and renowned longevity.

  39. Avatar
    chat iraq over 4 years later:

    Great Article very nice

  40. Avatar
    Dolce and Gabbana over 4 years later:

    thanks very much for share with us

  41. Avatar
    Headset over 4 years later:

    Myth: nutrition is not better.”Nutrition” can not lack, cheap beats by dr dre Solo HD but not better.Also to the protein, for example to illustrate the “nutritional” amount of importance. cheap beats by dr dre Dr. Dre Tour Growth and development of children is not enough if the intake of protein, it will affect height, weight, and intelligence and other aspects of normal development.So many people in addition to food intake of protein, cheap beats by dr dre it also eat a little protein powder.

  42. Avatar
    cheap ralph lauren polo shirts over 4 years later:

    Welcome to buy Cheap Ralph Lauren polo shirts online. Our ralph lauren polo shirts outlet store sell all kinds of cheap ralph lauren sweaters for men and ralph lauren jackets for women and ralph lauren polo for kids. We promise: all ralph lauren saleshere are best quality. You need not worry about the quality. Whether worn as an exterior shell, or a standalone jacket, this cheap Ralph Lauren polo shirts is ideal for mild aerobic activities in challenging, inclement weather. And prices of these

  43. Avatar
    calvin klein underwear over 4 years later:

    Our good reputation online store offers a number of popular products calvin klein underwear. All products is wholesale price. We offered many brand of calvin klein boxers, mens calvin klein underwear, calvin klein underwear, oakley sunglasses on sale, ck underwear,adidas shoes, red bull caps, belts, our web would calvin klein underwear sale be the best choice. Everyone will love them. fast delivery,discount price and 100% top quality guarantee.

  44. Avatar
    Tips For Bowling over 4 years later:

    The people in general ought to have regard to the moral character of those whom they invest with authority either in the legislative, executive, or judicial branches.

  45. Avatar
    alwadifa over 4 years later:

    I liked you blog so im going bookmark it with my prefered websites

  46. Avatar
    Backup iPhone SMS over 5 years later:

    Make it possible to backup all stuff including contacts and text messages to computer and restore to iPhone when necessary.

Comments