ways to split big modules ? 
Author Message
 ways to split big modules ?

I've quite a big perlmodule that has about 7000 lines of code.
Imho thats too much lines for a single file, so I try to outsource parts of
it to external files/modules.

It was easy to exclude parts that were isolated and could easily be
transformed in objects that are defined in outer modules.

But now I've many methods left that relies on each other.
IMHO the easiest way  would be to just cut/paste the code to external files
and require this files in the mainfile. Unfortunately mod_perl (which is
used as perlinterpreter) demands the full path in the require-statements
and therefore the whole module gets difficult to install.

By now I just exclude the subs in external modules and reimport them by

methods for the mainobject.

But as soon as extmodule1 requires subs in extmodule2 troubles begins.

Best way would be to reorganize the whole module and seperate into logical
objects, but I'd like to hear how other people split big projects into
several files.

I'm also interested if it costs much extra time if using many small modules
instead of one big module and if its better to use module-structures like

mymodules::main
mymodules::extra1
mymodules::extra2

or

mymodules::main
mymodules::main::extra1
mymodules::main::extra2

thnx,
peter

--
peter pilsl

http://www.*-*-*.com/



Wed, 14 Sep 2005 11:46:19 GMT  
 ways to split big modules ?

Quote:

> I've quite a big perlmodule that has about 7000 lines of code. Imho
> thats too much lines for a single file, so I try to outsource parts
> of it to external files/modules.
> [snip]
> Unfortunately mod_perl (which is used as perlinterpreter) demands
> the full path in the require-statements and therefore the whole
> module gets difficult to install.

You could include this in the beginning of mymodules::main:

     use lib '/full/path/to/local/library';
     if ($ENV{MOD_PERL}) {
         require mymodules::extra1;
         require mymodules::extra2;
     }

Assuming that the main module is always used or required, that would

wouldn't be necessary. The only thing you would need to think of when
installing the module is editing the path in the "use lib" statement.

/ Gunnar

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



Wed, 14 Sep 2005 13:29:08 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. split a big program into main + (optional) advanced

2. split the big file

3. Seeking advice on semantics (pros / cons and best ways of) using constants across modules

4. A big associative array - How big is it!

5. big import big mess!!!!

6. Convertaing BIG BIG integers to HEX

7. Randal's Big Day in Big D

8. How big is big?

9. Should modules be used in a big project?

10. Accuracy of various Big Integer Modules?

11. which module to use for big integer math

12. split in a module spins down my machine?!?!?

 

 
Powered by phpBB® Forum Software