Search the web
Sign In
New User? Sign Up
testdrivendevelopment · Test-driven Development
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
The first test - Hardest part about TDD?   Message List  
Reply | Forward Message #28244 of 32009 |
Re: [TDD] The first test - Hardest part about TDD?

2008/5/19 Andreas Krügersen <a.kruegersen@...>:
> Hi All,
>
> I've used TDD for some time now but rather in an inside-out fashion, i.e.
instead
> of thinking about user stories encompassing the whole application first, I
used
> TDD to drive small parts. For example I knew "I need that component A now" and
> then wrote tests for it before implementing it.
>
> Now I'd like to start with an outside-in design (i.e. story-based) since my
previous approaches
> proved to be unsatisfying in the long run. But I find it really hard to come
up with the first
> test to get things rolling.
>
> The situation is as follows:
> I'd like to write an application for a mobile device (with Java ME for all of
you who have
> worked with it yet) that renders a certain animation. That is, it should just
have a canvas
> and keep drawing the animation forever.
> As a general design decision, I want to use the Presenter-First technique
> (http://www.atomicobject.com/pages/Presenter+First) for the whole application.
>
> So I spent some thoughts on this and I finally came up with the idea that I
should
> have a test like "When the next frame is drawn, the view uses the current
coordinates
> stored in the model to draw the outline of the animation". In
presenter-first-speech this
> would result in a model storing coordinates for my animation, a view
representing the
> canvas and a presenter connecting both the view and the model. Thus, the test
would
> be written for the presenter.
>
> But then I realized that this is already "inside" of the application and not
the outside.
> An outside test would probably be something like "When the application starts,
the canvas
> is shown empty". Yet I don't really have a clear picture in my mind of how the
whole thing
> should evolve from there.
>
> I still find it very difficult to think in "application-wide stories" rather
than in
> "component- or class-wide stories". It's much easier to think of how a
specific class fits into an
> existing picture than defining the frame for the whole application with a
single test.
> What do you think how I should start driving this application? What should I
use as the first test and how
> should I go on? For me, the first test in outside-in design to get started is
really the hardest
> part about TDD. Perhaps some of you have experienced similar problems?
>

From my viewpoint, this is TDD done the BDD way. I'm trying to learn
the BDD practice in C#/NUnit. I've been using TDD the way you describe
(bottom-up) for 2 years now, and it's been mostly a _great_
experience. The thing that bothers me most with "classic TDD" is that
sometimes I build too much functionality in my classes, which isn't
used in the end application after all. Even whole objects are wasted
in the worst case.

So I'm going through the same thing, my play-app is a simple console
app: GenTODO.exe. It's supposed to generate an HTML report from
scanning *.cs files searching for // TODO-comments. I find it hard to
go past the first test:

----------------
interface ILister { void List(string path, string pattern); } // recursive!
interface IWriter { void Write(string path, string content); }
public void should_create_report_file() {
string scanPath = "somepath";

DynamicMock lister = Mock(typeof<ILister>);
lister.ExpectAndReturn("List", new string[]{"file1.cs", "file2.cs"},
scanPath, "*.cs");
lister.ExpectAndReturn("Load", "// TODO: implement this function",
"file1.cs");
lister.ExpectAndReturn("Load", "", "file2.cs");

DynamicMock writer = Mock(typeof<IWriter>);
writer.Expect("Write", "Report.html",
"<html><h1>file1.cs</h1><ul><li>Row 1: // TODO: implement this
function</li></ul></html>");

Generator generator = new Generator(lister, writer);
generator.ProduceReport(scanPath, "Report.html");

lister.Verify();
writer.Verity();
}
----------------

Both the ILister and IWriter interfaces will have "system border
implementations" -- direct I/O methods, so they're not really
candidates for further development (well I need them sooner or later,
but they're not candidates for BDDing). I do need some
source-code-analyzing-object, should it be injected too, or an
internal dependency (an implementation detail of generator)? In case I
injected it, it would be a candidate for further development. But the
feeling I get if I inject that dependency too, is "what is stopping my
generator from injecting every single dependency, all the way down to
the smallest class?".

/Olof

> regards
> Andreas Krügersen
>
> _______________________________________________________________________
> EINE FÜR ALLE: die kostenlose WEB.DE-Plattform für Freunde und Deine
> Homepage mit eigenem Namen. Jetzt starten! http://unddu.de/?kid=kid@mf2
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>


Thu May 22, 2008 6:10 am

olof.bjarnason@...
Send Email Send Email

Forward
Message #28244 of 32009 |
Expand Messages Author Sort by Date

Hi All, I've used TDD for some time now but rather in an inside-out fashion, i.e. instead of thinking about user stories encompassing the whole application...
Andreas Krügersen
wyverex42
Offline Send Email
May 22, 2008
3:43 am

... From my viewpoint, this is TDD done the BDD way. I'm trying to learn the BDD practice in C#/NUnit. I've been using TDD the way you describe (bottom-up) for...
Olof Bjarnason
olof.bjarnason@...
Send Email
May 22, 2008
6:14 am

... I completely fail to grok this. "Classic TDD" was introduced in the context of Extreme Programming, where the order of the day was "You Ain't Gonna Need...
heusserm
Offline Send Email
May 22, 2008
11:51 am

I suppose one way to understand Olof's remark is that he starts out creating code as part of the TDD process which is eventually removed completely as he...
Donaldson, John (GEO)
geo_johnfr
Offline Send Email
May 22, 2008
11:56 am

... Sure. Just as when I start my bowling game score method as: return 0; and later replace the 0 with return result; and insert some result-calculating code...
Ron Jeffries
ronaldejeffries
Offline Send Email
May 22, 2008
1:20 pm

... I have often walked by construction sites and seen scaffolding during the project. I never see the scaffolding after the project is completed. I have never...
J. B. Rainsberger
nails762
Offline Send Email
May 27, 2008
2:51 pm

... Well, strictly speaking the "return 0" was not test/spec-code but evolving production code. So the scaffold-analogy is not that 1-1 this time. The "return...
Olof Bjarnason
olof.bjarnason@...
Send Email
May 27, 2008
3:01 pm

... I agree. When I test-drive the method Fraction.plus() in my TDD demo, I do use scaffolding when I add an intValue() method to defer implementing equals()...
J. B. Rainsberger
nails762
Offline Send Email
May 28, 2008
2:18 pm

On Wed, May 28, 2008 at 10:18 AM, J. B. Rainsberger ... I believe the word you're searching for is "overhead". That's wasteful if it's not necessary (like...
Björn Gustafsson
bjorn_ga
Offline Send Email
May 28, 2008
2:29 pm

... The word "overhead" doesn't match the image I have when I think about "line drawn with pencil". The latter makes me think of a "sketch", which we could use...
J. B. Rainsberger
nails762
Offline Send Email
May 28, 2008
3:05 pm

Hello, Björn. On Wednesday, May 28, 2008, at 10:29:03 AM, you ... I think it's easy to imagine that sketching the painting in pencil first is overhead,...
Ron Jeffries
ronaldejeffries
Offline Send Email
May 28, 2008
3:06 pm

On Wed, May 28, 2008 at 11:06 AM, Ron Jeffries ... I disagree with your implied assertion that overhead == waste, or even "necessary waste". You're right that...
Björn Gustafsson
bjorn_ga
Offline Send Email
May 28, 2008
3:27 pm

Hello, Björn. On Wednesday, May 28, 2008, at 11:27:51 AM, you ... Actually that's not my assertion at all. I think the pencil line is part of the art,...
Ron Jeffries
ronaldejeffries
Offline Send Email
May 30, 2008
6:22 pm

On Fri, May 30, 2008 at 12:21 PM, Ron Jeffries ... The sketch is necessary to create the art, but maintaining the sketch over time to match the final painting...
Kelly Anderson
kellycoinguy
Online Now Send Email
Jun 4, 2008
8:09 pm

... I believe the discussion was about something like: int MyMethod(...) { return 0; } .. being first production code after the first test case had been...
Olof Bjarnason
olof.bjarnason@...
Send Email
Jun 5, 2008
5:21 am

On Wed, Jun 4, 2008 at 11:21 PM, Olof Bjarnason ... Yes, and once you have the real code, you are happy to be done with the return 0; Deleted code ==...
Kelly Anderson
kellycoinguy
Online Now Send Email
Jun 6, 2008
1:10 am

JB, ... <snip/> ... To paraphrase something Ron said a while back, what if you could find a way to safely build the building without scaffolding?... wouldn't...
Matt
maswaffer
Offline Send Email
May 27, 2008
3:35 pm

... I suppose that's true. To me it's a matter of the use of the word. You and I can call it waste and understand what we mean by that. Still, I wouldn't go...
J. B. Rainsberger
nails762
Offline Send Email
May 28, 2008
2:10 pm

JB, ... <snip/> ... By this do you mean that people might think it should simply be eliminated rather than replaced with a more efficient process? If we call...
Matt
maswaffer
Offline Send Email
May 28, 2008
3:19 pm

... That does not convince me. "Necessary waste" sounds to me as silly as "optional requirement". This gives me a clue that I do not want to call such things...
J. B. Rainsberger
nails762
Offline Send Email
May 29, 2008
2:37 am

JB, ... until ... This surprises me. "Necessary waste" is not a term I coined... people a lot smarter than me came up with it. In the Lean reading that I...
Matt
maswaffer
Offline Send Email
May 29, 2008
5:06 am

... I don't like the phrase, even though I like you fine. It reads as an oxymoron, that's all. ... If not submitting TPS reports causes me to lose my job, then...
J. B. Rainsberger
nails762
Offline Send Email
May 29, 2008
1:31 pm

@Matt, @John and @Ron. Say I want to solve a problem A. With my experience, I can visualize a solution consisting of two subproblems a and b, two "helper...
Olof Bjarnason
olof.bjarnason@...
Send Email
May 22, 2008
9:00 pm

... I might be able to help with a real problem. I can't do much with an imaginary one ... Ron Jeffries www.XProgramming.com Some things are impossible. And...
Ron Jeffries
ronaldejeffries
Offline Send Email
May 22, 2008
9:17 pm

... Solve A first. Perhaps the a and b you envision will appear in that solution and perhaps not. It surprises me how often not. - George -- ... * George...
George Dinwiddie
gdinwiddie
Offline Send Email
May 22, 2008
10:59 pm

I fully agree. Solve A. Ideally a & b would be contained within A and you may or may not have to refactor them out. May be you would refactor a _c_ out :-)....
Sriram Gopalan
mgsram
Offline Send Email
May 23, 2008
1:17 am

I think the answers of "solve A first" show succinctly that a large proportion of minimising refactoring in TDD (and in any code) is experience ... the sooner...
Casey Charlton
caseycharlton69
Offline Send Email
May 23, 2008
6:20 am

... Casey, I think that experience is always helpful in getting something right the first time. And that experience is earned by getting things wrong many...
George Dinwiddie
gdinwiddie
Offline Send Email
May 23, 2008
1:39 pm

Hello John, When you created tests for * - set text - click button - expect other text * I m curious as to what was the object under test ? I have been TDDing...
Sriram Gopalan
mgsram
Offline Send Email
May 22, 2008
11:58 am

Sriram, I guess the nearest concept under test would be 'view'. But, in fact I wrote something like: WidgetForm wf = new WidgetForm(); Wf.QuestionText = "xyz";...
Donaldson, John (GEO)
geo_johnfr
Offline Send Email
May 22, 2008
12:16 pm
First  | < Prev  |  Last 
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help