Warning - bit of a ramble below!<br><br><div><span class="gmail_quote">On 29/01/2008, <b class="gmail_sendername">Edvard Majakari</b> &lt;<a href="mailto:edvard@majakari.net">edvard@majakari.net</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
&gt; Not if you fill it out...and the BDD way is to write one example at a<br>&gt; time, not a complete spec beforehand.<br><br>I&#39;ve done it this way too (being lazy), but is it really good thing?<br>Often I get more insight on how an interface should look like,<br>
if I think even superficially what kinds of services an object should<br>offer. Thus I _think_ that writing a TODO-list in spec form<br>(marking all as pending) and starting to pick up those that you want<br>to do. Is this really considered non-BDDish by the authoritatives?<br>
<br>If I remember correctly, Dave Astels wrote something along these lines<br>in his book Test Driven Development<br>(reminding that BDD is TDD done right): create a TODO list of small<br>tasks to do, related to roles of the object, and pick something<br>
start writing tests.</blockquote><div><br>You make some good observations.<br><br>The advice to &quot;pick something and start writing tests&quot; was one of the alarm bells early on that told me TDD was about more than testing. I write software to solve a problem - especially commercial software - and there is usually a stakeholder involved who wants to see tangible progress.<br>
<br>With respect, BDD is more than TDD-done-right. &quot;Full-scale&quot; BDD (starting at the outside with stories and scenarios and working inwards to the code) grew out of trying to identify &quot;the next most important thing&quot; from the stakeholder&#39;s perspective, rather than whatever looked most interesting to me as a programmer.<br>
<br>If you only have the close-up view of TDD - or example-level BDD (which unfortunately is what most people consider BDD to be) - it&#39;s difficult to see what the most valuable behaviour would be, and therefore the next most important thing to implement, so you end up choosing &quot;somewhere interesting&quot; (i.e. somewhere arbitrary in business terms). Without business-level acceptance criteria in the form of scenarios you don&#39;t know what &quot;done&quot; looks like, so it&#39;s very tempting to capture a whole bunch of things that occur to you in case one of them is the way forward. That&#39;s when you find yourself writing a bunch of &quot;todo&quot; or pending examples.<br>
<br>If you start with a narrow, end-to-end piece of functionality and drill into it from the outside, right through until you have it working, you will find that at each layer of abstraction you will have a pretty focused subset of behaviour to implement to get the job done.<br>
</div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">IMO, if you don&#39;t think of the features at all and just start to spec<br>completely some single functionality, you risk rewriting that test<br>
many times<br>when you add new tests for other methods on the same object, no?</blockquote><div><br>You certainly risk revisiting something many times - often assumptions you made in speccing out the object without any outside-in forces to identify its actual value. If I&#39;m honest, I find myself doing this more often than I would like, especially when I&#39;m reworking legacy code (which is a lot of my time recently). I usually take it as an indication that I haven&#39;t broadened my scope enough - I&#39;m not &quot;outside&quot; enough to have a reasonable perspective. I stop, take a couple of steps back (usually reverting all my recent changes!) and reassess exactly who is the client of the code I&#39;ve been tinkering with.<br>
<br>I can relate to your point about writing a few examples to help you understand how an interface might work. Massaging code like that is a great way to explore an API. The important thing is to recognise it as just that - an exploratory exercise. Then you throw away any code you created in the process and start over, outside-in, armed with the knowledge that came out of the spike.<br>
<br>Perhaps I ought to write this up - it&#39;s a theme that comes up quite often.<br><br>Thanks for listening,<br>Dan<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
--<br>&quot;One day, when he was naughty, Mr Bunnsy looked over the hedge into<br>Farmer Fred&#39;s field and it was full of fresh green lettuces. Mr<br>Bunnsy, however, was not full of lettuces. This did not seem fair.&quot;<br>
&nbsp;&nbsp;-- Terry Pratchett, Mr. Bunnsy Has An Adventure<br>_______________________________________________<br>rspec-users mailing list<br><a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br><a href="http://rubyforge.org/mailman/listinfo/rspec-users">http://rubyforge.org/mailman/listinfo/rspec-users</a><br>
</blockquote></div><br>