Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: To sub or not to sub, that is the question?

by jplindstrom (Monsignor)
on Jun 25, 2001 at 06:02 UTC ( #91165=note: print w/replies, xml ) Need Help??


in reply to To sub or not to sub, that is the question?

Do things once, no more.

Like the third normal form in database design, it's a noble vision; you may decide to violate the rule for practical reasons. But it better be a good reason :)

In this case it might be readability, but I would try to counter that problem with a good naming convention and properly defined (yes, documented) interfaces first.

<Drifting off-topic> Actually, I wrote an essay about Object Oriented Maintenance once which discussed an interesting problem in this area. Object oriented code tend to contain a lot of small (few lines, like 3-6) methods. Each method is easy to understand, but the overall system understanding is more difficult due to the "fragmented" nature of the code (and other OO things, like late binding).

The studies I used in my essay contained mostly Smalltalk code, other languages had other but similar charachteristics. As for Perl... well, TMTOWTDI.

<Further off-topic> The solution I suggested for this lack of system overview was better dev tools. With class browsers and automated documentation systems things improve. And POD is a truly great thing with Perl.

  /J

Update:

Both "Code Complete" and "The Pragmatic Programmer" contain advice regarding subroutines.

  • Comment on Re: To sub or not to sub, that is the question?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://91165]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2020-01-24 03:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?