Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: (Zigster) How to split code into subsby zigster (Hermit) |
on May 04, 2001 at 14:02 UTC ( [id://77915]=note: print w/replies, xml ) | Need Help?? |
To quote another node: Re: Silly code reviews and shift
Re reading your question, I seem to detect a query about how to split up your code. How much to put into subs and how much in the main body. Asside from obvious sub candidates to prevent code duplication; consider the following. A technique often used is to write pseudo code in terms of comments. Then replace each comment with a block of code. I then look at each block of code and consider how valuable the comment is. Does the code describe itself such that the comment is not required, if it does I leave it alone. If the comment is still required then I would move the code to a sub to simplify the main block. This pulls out complex code, allowing for nice partitianing and easier maintenence. I then apply a similar process to all subs. Consider as a rule of thumb not allowing any sub to contain any more code than you can fit onto your screen at a time. Consider the 'main block' as just another sub. ALWAYS KISS ;-)
UPDATE
HTH -- Zigster
In Section
Seekers of Perl Wisdom
|
|