Thank you for you two answers.

You are both saying : "your program is simple, just do things one after the other, you probably don't need objects." (and giving me examples of how you use TDD, thank you)

Practically I agree, BUT
my question is more theoretical than practical.
I am trying to understand key concepts on a (too) simple example. And i think in a way, i finally understood that my question is "bottom-up or top-down design?". Could anybody confirm this? This is all new vocabulary to me, so i would appreciate if someone experienced told me whether i am understanding the concepts properly or not.

When i will build a bigger, more complex program, i will have the same question again : should i first start building low-level objects (bottom-up approach), thus basing my design on assumptions about external inputs? Or shall i go "outside-in", first interacting with my external peers, and then delegating responsibilities to new lower-level classes when i see that i need to.

The programer who wrote this article prefers a top-down approach , because he doesn't like to base a design on assumptions, and thus write useless code.
While this one prefers bottom-down, because it (would) result in more loosely-coupled elements of reusable code; and it requires a lot less stubs or mocks while in development.

These questions are important to me. Sure, i don't want to become a "purist", and to make my life complicated on simple problems all the time. But i am just trying to learn how to design highly maintainable, loosely-coupled code. And if there are several ways to do it, i'd rather learn about them.

~ ~ ~
I don't find it today, but yesterday i read this blog entry by chromatic, saying that he likes to use the smallest possible objects and roles as possible. And i read it in a few other places too. I guess it sounds as if it was "more work", and people will say "why are you being so complicated?" But it also gives maintainability and flexibility. And i don't think that "more classes = more work", as creating classes is so simple with Moose.

PS : thank you for pointing at Test::XT


In reply to Re^2: Test Driven Development example + design question by mascip
in thread Test Driven Development example + design question by mascip

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.