“TDD is best used when the requirements are clear.”
And I counter that TDD is best used to clarify the requirements.
Chicken, meet egg.
“TDD is best used when the requirements are clear.”
And I counter that TDD is best used to clarify the requirements.
Chicken, meet egg.
@jasongorman when it's very unclear I like to experiment more though. I typically do write a test, but very high level and typically with a debug statement at the end so I can play around a bit. When I have clearer what I want I throw away (or comment out) my code and rebuild with TDD.
Sometimes this leads to the same code, but more often than not I end up with a better interface
@stevefenton @jasongorman @kentbeck when I was in college I learned that most of the work was in the thinking/discovering/learning and only very little in the code itself.
Mind you, this was no official lesson. In one of my first courses I had to write an XSLT and I didn't know XSLT and it was hard and it was done over the course of two months.
Then my editor asked: "the file has changed on disk, do you want to reload". I thought, sure why not. 1/2
@stevefenton @jasongorman @kentbeck but as it turned out, I was over my quota, so my last save had left the file empty.
I was going to be evaluated in an hour, and I actually was able to reproduce the XSLT in an hour.
This was a surprisingly useful lesson! 2/2
I'm with *agile*, in that we really only need sufficient "requirements" to do the work that we're about to do. And most of that can be "informal" communication.
(OK; a bit more, for overall project planning and direction, but not much.)
And I go a lot further than that. I hate the word "requirements." I say that it's misleading fiction. We have lots of "want to haves," but very few strict *Requirements*.
…
And I recently noticed that I differ significantly from (at least) common pre-agile assumptions/"knowledge," in that, …
For prototypes, demos, exploratory work, etc., I find that …
*Fewer and less detailed requirements is BETTER!!!*
Like, "Give me some breathing room, man!"
For a quick, throw-away demo or prototype, I want a rough outline, with goals we want to accomplish. *NOT* a detailed field-by-field and attribute-by-attribute Formal Specification, with QA Test Cases, etc
(on Requirements for a prototype or demo, ...)
pre-agile people say
"But you might not have *ALL* the requirements!!!"
I say, "Nonsense!"
"The purpose of this demo is to show that we can add a couple of fields to these vendor-built tables and screens, and enter customer-specific data. The question of precisely what each label text is, exactly how wide each field is (visually), etc, etc, etc, etc, … is mostly time-wasting nonsense."
It's Throw Away code!
@jasongorman
To me, it's just a different way of looking at the situation. It's not hard; just novel. Once you've done it, it opens up new possibilities.
A half-step that I've found helpful is using a unit test framework to explore a library or API--calling with known values and asserting that the result is an empty string. This uses the test framework to explore and tell you how that call works.
It's a short step from their to doing similar with your own code.
I say,
"TDD is best used to ensure that the code you're writing does exactly what you intend for it to do. Nothing more. Nothing less."
But somehow some people think that a legitimate "objection" is, …
"But what about when I don't know what the code should do? I can't do TDD then!!!"
I think, …
"Buddy, if you have no idea even what *you* want the code to do, then PLEASE STOP!!! You're doing more harm than good. This will NOT work out well."