Perl Best Practices
Any fool can make things bigger, more complex, and more violent. It takes a touch of geniusand a lot of courageto move in the opposite direction. Albert Einstein
Code reuse is a core best practice, and modules are Perl's principal large-scale mechanism for code reuse. They are also at the heart of Perl's greatest software asset: the CPAN. Refactoring source code into modules will not only increase the reusability of that code, it is also likely to make the code cleaner[*] and easier to maintain. If nothing else, the programs from which the original code is removed will become shorter, better abstracted, and consequently more maintainable. [*] Because revisiting any existing piece of code is likely to make it cleaner, once you get over the involuntary twitching. The keys to good module design and implementation are: designing the interface first, keeping that interface small and functional, using a standard implementation template, and not reinventing the wheel. The guidelines in this chapter explore these issues. |