Portal Home |  IS News Menu |  Portal Menu |  ISB Menu |  Main Content
Perl Best Practices
03 Aug 01:32

Perl Best Practices just published by O'Reilly is a collection of guidelines to help programmers produce the best code possible.

Every programmer has a unique approach to writing software--a unique coding style. "Programmers' styles are based on their earliest experiences in programming - the linguistic idiosyncrasies of their first languages, the way in which code was presented in their initial textbooks, and the stylistic prejudices of their early instructors," author Damian Conway explains. "That style will develop and change as the programmer's experience and skills increase. Indeed, most programmers' style is really just a collection of coding habits that have evolved in response to the opportunities and pressures they have experienced throughout their careers."

Conway further observes that just as in natural evolution, those opportunities and pressures may lead to a coding style that is fit, strong, and well adapted to the programmer's needs. "Or it may lead to a coding style that is nasty, brutish, and underthought. But what it most often leads to is something even worse: Intuitive Programmer Syndrome."

According to Conway, many programmers code by instinct. "They aren't conscious of the hundreds of choices they make every time they code: how they format their source, the names they use for variables, the kinds of loops they use," and so on. The Intuitive Programmer writes code in a way that feels natural, happens intuitively, and feels good, but doesn't necessarily result in the best code possible.

In Perl Best Practices, Conway sets forth 256 guidelines that are designed to help programmers produce code that is clear, robust, efficient, maintainable, and concise. There are many ways of measuring code quality, and Conway doesn't profess that his is the only approach. Instead, he offers a set of best practices that is "coherent, widely applicable, balanced in its aims, and is based on real-world experience of how code is actually written, rather than on someone's ivory tower theories on how code ought to be created."

The guidelines in the book cover code layout, naming conventions, choice of data and control structures, program decomposition, interface design and implementation, modularity, object orientation, error handling, testing, and debugging. Above all, it's a set of practices that actually works, and that many developers around the world are using already. Much like Perl itself, the guidelines are about helping programmers get their jobs done, without getting in the way.

Conway doesn't expect experienced Perl developers to like all the suggestions in his book. They'll find some of them unnatural or counterintuitive, while others will feel excessively rigid and un-Perlish. Or, perhaps they'll just seem unnecessarily different from long-ingrained coding habits. He urges programmers to set those feelings aside as they read, and review the advice in the book as they would any other proposed code enhancement.

Related links: (Open in a new window.)
External link www.oreilly.com/catalog/perlbp/index.html

View Printable View printable version (opens in new window)
Back Back