I'm in a similar position to yourself and I've made a few tentative steps toward this testing malarky - so far so good.

One method I have found useful is as the "script become larger and larger" I make them smaller. :-) What I mean is to break the script up into subs that do the detail work leaving the main script quite short. If you choose meaningful names for your subs it helps you 'see' what the app is about (I quite like to get that part fit on the screen). Write your subs so that everything it needs is passed in as an argument, perhaps a hash ref, with no reliance on any globals. It is then possible to write a 'demonstrator' script with just that sub in it. Pass in various permutations of arguments and study what it returns.

I like subs that fit on a screen too and sometimes they have little helper subs and this also helps to see what is going on. You can write your 'main' script straight away (a flow chart, if you will) and write and test each sub one at a time.

When you find your subs can be logically grouped together, along with their helpers, there may be a case for grouping them together in a module. It may be that having the module represent itself as an object with methods and properties would be helpful, "look mom! I've got an API!". With some careful planning you could find it reusable. Get a few well organised modules and your script is back to 5 lines again!

What I'm finding is if that is how you've developed your app it is very ameanable to testing, in fact it could be argued that the method I've described is just an inefficient approach to testing. I have lots of tests, why not organise them? We'll see how I get on. :-)

Before your app gets too large be sure to have a thorough look at CPAN. Are you sure no one has trod this path before? CPAN is often the best and quickest way to cut _your_ app down to size cuz someone else has already done the hard work.

My approach hasn't changed much in other respects though. Absolutely nothing gets done until I start writing code. It's what I like doing, all suggestions to do otherwise are cheerfully ignored.

Good luck, and start coding! :-)


In reply to Re: Perl Software Design Process by wfsp
in thread Perl Software Design Process by TeraMarv

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.