Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Code reuse and clean packages

by paulbort (Hermit)
on Jun 10, 2004 at 17:33 UTC ( #363128=note: print w/replies, xml ) Need Help??

in reply to Code reuse and clean packages

In addition to the very wise suggestions already made, I'd like to add an intermediate method, between the two extremes of 'leave it alone' and 'lots of little packages in proper namespaces'.

First divide the functions into logical groups. Graphics in one pile, IPC in another, DB in a third, and don't be afraid to have one pile called 'general' or even 'misc'. If there is some code that might go to CPAN, and some that is proprietary, keep that in mind.

Those piles are reasonable candidates for becoming libraries as they stand, with one extra consideration: You may want to re-arrange them to reduce dependencies.

For example, if you put the function that filters CGI input in the HTML generation module, but an importer module needs to use just that function, and doesn't generate HTML, then that function should probably live in the 'general' library.

Depending on how you build the libraries, you might not have to do weeks of work to make this happen. My first cut at this for my current project involved making modules that were just a big pile of sub foo {...}, and a simple use MyModule gets all of those functions into your namespace. So you can automate some of the conversion process by removing the use you already have, doing a syntax check, and then adding the new use for the individual modules needed. Unless you have thousands of scripts, this shouldn't take weeks. (N.B.: A powerful editor will help. Notepad is not a powerful editor.)

Spring: Forces, Coiled Again!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2019-07-18 08:57 GMT
Find Nodes?
    Voting Booth?

    No recent polls found