in reply to Perl Software Design Process
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! :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl Software Design Process
by TeraMarv (Beadle) on Mar 05, 2008 at 14:29 UTC |