|
Writing Perl Modules for CPAN Authors: Tregar S. Published year: 2002 Pages: 21-24/110 |
Read the Fine ManualsMuch of the information in this chapter is also available in the documentation that comes with Perl. As an added bonus, Perl's documentation will be kept up-to-date as Perl changes, so you might find information on features that don't even exist as I'm writing. Table 2-5 provides a list of documents in which you can expect to find more information about the areas I've covered.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||
SummaryThis chapter has equipped you with the knowledge necessary to create modules in Perl. You've learned how to create both functional and object-oriented modules. Furthermore, you've been initiated into the magic art of tied and overloaded modules. In the next chapter, I'll show you how to take this technical knowledge and use it to create high-quality modules. |
|||||||||||||||||||||||||||||||||
Chapter 3: Module Design and Implementation
OverviewPROGRAMMING IS BOTH science and art. The last chapter equipped you with the science of modular programming in Perl—the syntax and behavior of modules. This chapter will present the other side—the art of designing and implementing modules. Just by using modular programming you're ahead of the programming pack— the majority of working programmers spend their days desperately writing one-off scripts in a dialect of Perl akin to BASIC. That said, there are good modules and there are bad modules. This chapter will help you write modules that resemble the former more than the latter. I expect you to treat the advice given critically—the best design technique to use will depend on your aesthetics, and that's the last thing I want to dictate ! Ultimately, there's only one inviolate rule of software design: Do it. It's worth it. The satisfaction you gain from jumping into the fray with some impulse coding won't last when the first wave of bug reports and unexpected changes lands. I'll leave it to the management books to break out the charts and graphs; if you give it a try you'll soon convince yourself. Every moment of thought and planning you put into a project at the outset will be paid back in spades by the end. It's a rare task that's really so small that it's worth knocking off without consideration. |
|||||||||||||||||||||||||||||||||
Check Your SlackBefore you start a new module, you should visit CPAN. [1] You may be able to avoid a lot of work (and thus gain a lot of slack) by reusing an existing module. If you need features that an existing module doesn't provide, consider extending the module. Object-oriented modules can usually be extended through inheritance. If you make changes to a CPAN module, consider contributing those changes back to the author. [2] Remember, one of the virtues of a Perl programmer is laziness ; CPAN is the greatest enabler of programmer laziness since the terminal!
[1] See Chapter 1 for copious instructions.
[2] If you'll be distributing your module, then you may be required to release the source for any changes under the same license as the module. Be sure to read the license for the module before you start making modifications! |
|||||||||||||||||||||||||||||||||
|
Writing Perl Modules for CPAN Authors: Tregar S. Published year: 2002 Pages: 21-24/110 |
![]() Perl and XML | ![]() Perl Testing: A Developer's Notebook | ![]() Perl Hacks: Tips & Tools for Programming, Debugging, and Surviving | ![]() Higher-Order Perl: Transforming Programs with Programs | ![]() Mastering Algorithms with Perl |