Perl Best Practices: Standards and Styles for Developing Maintainable Code

Perl Best Practices: Standards and Styles for Developing Maintainable Code

by Damian Conway
Perl Best Practices: Standards and Styles for Developing Maintainable Code

Perl Best Practices: Standards and Styles for Developing Maintainable Code

by Damian Conway

eBook

$23.99  $31.99 Save 25% Current price is $23.99, Original price is $31.99. You Save 25%.

Available on Compatible NOOK Devices and the free NOOK Apps.
WANT A NOOK?  Explore Now

Related collections and offers


Overview

Many programmers code by instinct, relying on convenient habits or a "style" they picked up early on. They aren't conscious of all the choices they make, like how they format their source, the names they use for variables, or the kinds of loops they use. They're focused entirely on problems they're solving, solutions they're creating, and algorithms they're implementing. So they write code in the way that seems natural, that happens intuitively, and that feels good.

But if you're serious about your profession, intuition isn't enough. Perl Best Practices author Damian Conway explains that rules, conventions, standards, and practices not only help programmers communicate and coordinate with one another, they also provide a reliable framework for thinking about problems, and a common language for expressing solutions. This is especially critical in Perl, because the language is designed to offer many ways to accomplish the same task, and consequently it supports many incompatible dialects.

With a good dose of Aussie humor, Dr. Conway (familiar to many in the Perl community) offers 256 guidelines on the art of coding to help you write better Perl code--in fact, the best Perl code you possibly can. The guidelines 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.

They're designed to work together to produce code that is clear, robust, efficient, maintainable, and concise, but Dr. Conway doesn't pretend that this is the one true universal and unequivocal set of best practices. Instead, Perl Best Practices offers coherent and widely applicable suggestions based on real-world experience of how code is actually written, rather than on someone's ivory-tower theories on howsoftware ought to be created.

Most of all, Perl Best Practices offers guidelines that actually work, and that many developers around the world are already using. Much like Perl itself, these guidelines are about helping you to get your job done, without getting in the way.

Praise for Perl Best Practices from Perl community members:

"As a manager of a large Perl project, I'd ensure that every member of my team has a copy of Perl Best Practices on their desk, and use it as the basis for an in-house style guide."-- Randal Schwartz

"There are no more excuses for writing bad Perl programs. All levels of Perl programmer will be more productive after reading this book."-- Peter Scott

"Perl Best Practices will be the next big important book in the evolution of Perl. The ideas and practices Damian lays down will help bring Perl out from under the embarrassing heading of "scripting languages". Many of us have known Perl is a real programming language, worthy of all the tasks normally delegated to Java and C++. With Perl Best Practices, Damian shows specifically how and why, so everyone else can see, too."-- Andy Lester

"Damian's done what many thought impossible: show how to build large, maintainable Perl applications, while still letting Perl be the powerful, expressive language that programmers have loved for years."-- Bill Odom

"Finally, a means to bring lasting order to the process and product of real Perl development teams."-- Andrew Sundstrom

"Perl Best Practices provides a valuable education in how to write robust, maintainable Perl, and is a definitive citation source when coaching other programmers."-- Bennett Todd"I've been teaching Perl for years, and find the same question keeps being asked: Where can I find a reference for writing reusable, maintainable Perl code? Finally I have a decent answer."-- Paul Fenwick"At last a well researched, well thought-out, comprehensive guide to Perl style. Instead of each of us developing our own, we can learn good practices from one of Perl's most prolific and experienced authors. I recommend this book to anyone who prefers getting on with the job rather than going back and fixing errors caused by syntax and poor style issues."-- Jacinta Richardson"If you care about programming in any language read this book. Even if you don't intend to follow all of the practices, thinking through your style will improve it."-- Steven Lembark"The Perl community's best author is back with another outstanding book. There has never been a comprehensive reference on high quality Perl coding and style until Perl Best Practices. This book fills a large gap in every Perl bookshelf."-- Uri Guttman

Product Details

ISBN-13: 9780596555023
Publisher: O'Reilly Media, Incorporated
Publication date: 07/12/2005
Sold by: Barnes & Noble
Format: eBook
Pages: 544
File size: 6 MB

About the Author

Damian Conway holds a PhD in Computer Science and is an honorary Associate Professor with the School of Computer Science and Software Engineering at Monash University, Melbourne, Australia.

Currently he runs an international IT training company—Thoughtstream—which provides programmer development from beginner to masterclass level throughout Europe, North America, and Australasia.

Damian was the winner of the 1998, 1999, and 2000 Larry Wall Awards for Practical Utility. The best technical paper at the annual Perl Conference was subsequently named in his honour. He is a member of the technical committee for The Perl Conference, a keynote speaker at many Open Source conferences, a former columnist for The Perl Journal, and author of the book Object Oriented Perl. In 2001 Damian received the first "Perl Foundation Development Grant" and spent 20 months working on projects for the betterment of Perl.

A popular speaker and trainer, he is also the author of numerous well-known Perl modules, including Parse::RecDescent (a sophisticated parsing tool), Class::Contract (design-by-contract programming in Perl), Lingua::EN::Inflect (rule-based English transformations for text generation), Class::Multimethods (multiple dispatch polymorphism), Text::Autoformat (intelligent automatic reformatting of plaintext), Switch (Perl's missing case statement), NEXT (resumptive method dispatch), Filter::Simple (Perl-based source code manipulation), Quantum::Superpositions (auto-parallelization of serial code using a quantum mechanical metaphor), and Lingua::Romana::Perligata (programming in Latin).

Most of his time is now spent working with Larry Wall on the design of the new Perl 6 programming language.

Table of Contents

Dedication; Preface; Contents of This Book; Conventions Used in This Book; Code Examples; Feedback; Acknowledgments; Chapter 1: Best Practices; 1.1 Three Goals; 1.2 This Book; 1.3 Rehabiting; Chapter 2: Code Layout; 2.1 Bracketing; 2.2 Keywords; 2.3 Subroutines and Variables; 2.4 Builtins; 2.5 Keys and Indices; 2.6 Operators; 2.7 Semicolons; 2.8 Commas; 2.9 Line Lengths; 2.10 Indentation; 2.11 Tabs; 2.12 Blocks; 2.13 Chunking; 2.14 Elses; 2.15 Vertical Alignment; 2.16 Breaking Long Lines; 2.17 Non-Terminal Expressions; 2.18 Breaking by Precedence; 2.19 Assignments; 2.20 Ternaries; 2.21 Lists; 2.22 Automated Layout; Chapter 3: Naming Conventions; 3.1 Identifiers; 3.2 Booleans; 3.3 Reference Variables; 3.4 Arrays and Hashes; 3.5 Underscores; 3.6 Capitalization; 3.7 Abbreviations; 3.8 Ambiguous Abbreviations; 3.9 Ambiguous Names; 3.10 Utility Subroutines; Chapter 4: Values and Expressions; 4.1 String Delimiters; 4.2 Empty Strings; 4.3 Single-Character Strings; 4.4 Escaped Characters; 4.5 Constants; 4.6 Leading Zeros; 4.7 Long Numbers; 4.8 Multiline Strings; 4.9 Here Documents; 4.10 Heredoc Indentation; 4.11 Heredoc Terminators; 4.12 Heredoc Quoters; 4.13 Barewords; 4.14 Fat Commas; 4.15 Thin Commas; 4.16 Low-Precedence Operators; 4.17 Lists; 4.18 List Membership; Chapter 5: Variables; 5.1 Lexical Variables; 5.2 Package Variables; 5.3 Localization; 5.4 Initialization; 5.5 Punctuation Variables; 5.6 Localizing Punctuation Variables; 5.7 Match Variables; 5.8 Dollar-Underscore; 5.9 Array Indices; 5.10 Slicing; 5.11 Slice Layout; 5.12 Slice Factoring; Chapter 6: Control Structures; 6.1 If Blocks; 6.2 Postfix Selectors; 6.3 Other Postfix Modifiers; 6.4 Negative Control Statements; 6.5 C-Style Loops; 6.6 Unnecessary Subscripting; 6.7 Necessary Subscripting; 6.8 Iterator Variables; 6.9 Non-Lexical Loop Iterators; 6.10 List Generation; 6.11 List Selections; 6.12 List Transformation; 6.13 Complex Mappings; 6.14 List Processing Side Effects; 6.15 Multipart Selections; 6.16 Value Switches; 6.17 Tabular Ternaries; 6.18 do-while Loops; 6.19 Linear Coding; 6.20 Distributed Control; 6.21 Redoing; 6.22 Loop Labels; Chapter 7: Documentation; 7.1 Types of Documentation; 7.2 Boilerplates; 7.3 Extended Boilerplates; 7.4 Location; 7.5 Contiguity; 7.6 Position; 7.7 Technical Documentation; 7.8 Comments; 7.9 Algorithmic Documentation; 7.10 Elucidating Documentation; 7.11 Defensive Documentation; 7.12 Indicative Documentation; 7.13 Discursive Documentation; 7.14 Proofreading; Chapter 8: Built-in Functions; 8.1 Sorting; 8.2 Reversing Lists; 8.3 Reversing Scalars; 8.4 Fixed-Width Data; 8.5 Separated Data; 8.6 Variable-Width Data; 8.7 String Evaluations; 8.8 Automating Sorts; 8.9 Substrings; 8.10 Hash Values; 8.11 Globbing; 8.12 Sleeping; 8.13 Mapping and Grepping; 8.14 Utilities; Chapter 9: Subroutines; 9.1 Call Syntax; 9.2 Homonyms; 9.3 Argument Lists; 9.4 Named Arguments; 9.5 Missing Arguments; 9.6 Default Argument Values; 9.7 Scalar Return Values; 9.8 Contextual Return Values; 9.9 Multi-Contextual Return Values; 9.10 Prototypes; 9.11 Implicit Returns; 9.12 Returning Failure; Chapter 10: I/O; 10.1 Filehandles; 10.2 Indirect Filehandles; 10.3 Localizing Filehandles; 10.4 Opening Cleanly; 10.5 Error Checking; 10.6 Cleanup; 10.7 Input Loops; 10.8 Line-Based Input; 10.9 Simple Slurping; 10.10 Power Slurping; 10.11 Standard Input; 10.12 Printing to Filehandles; 10.13 Simple Prompting; 10.14 Interactivity; 10.15 Power Prompting; 10.16 Progress Indicators; 10.17 Automatic Progress Indicators; 10.18 Autoflushing; Chapter 11: References; 11.1 Dereferencing; 11.2 Braced References; 11.3 Symbolic References; 11.4 Cyclic References; Chapter 12: Regular Expressions; 12.1 Extended Formatting; 12.2 Line Boundaries; 12.3 String Boundaries; 12.4 End of String; 12.5 Matching Anything; 12.6 Lazy Flags; 12.7 Brace Delimiters; 12.8 Other Delimiters; 12.9 Metacharacters; 12.10 Named Characters; 12.11 Properties; 12.12 Whitespace; 12.13 Unconstrained Repetitions; 12.14 Capturing Parentheses; 12.15 Captured Values; 12.16 Capture Variables; 12.17 Piecewise Matching; 12.18 Tabular Regexes; 12.19 Constructing Regexes; 12.20 Canned Regexes; 12.21 Alternations; 12.22 Factoring Alternations; 12.23 Backtracking; 12.24 String Comparisons; Chapter 13: Error Handling; 13.1 Exceptions; 13.2 Builtin Failures; 13.3 Contextual Failure; 13.4 Systemic Failure; 13.5 Recoverable Failure; 13.6 Reporting Failure; 13.7 Error Messages; 13.8 Documenting Errors; 13.9 OO Exceptions; 13.10 Volatile Error Messages; 13.11 Exception Hierarchies; 13.12 Processing Exceptions; 13.13 Exception Classes; 13.14 Unpacking Exceptions; Chapter 14: Command-Line Processing; 14.1 Command-Line Structure; 14.2 Command-Line Conventions; 14.3 Meta-options; 14.4 In-situ Arguments; 14.5 Command-Line Processing; 14.6 Interface Consistency; 14.7 Interapplication Consistency; Chapter 15: Objects; 15.1 Using OO; 15.2 Criteria; 15.3 Pseudohashes; 15.4 Restricted Hashes; 15.5 Encapsulation; 15.6 Constructors; 15.7 Cloning; 15.8 Destructors; 15.9 Methods; 15.10 Accessors; 15.11 Lvalue Accessors; 15.12 Indirect Objects; 15.13 Class Interfaces; 15.14 Operator Overloading; 15.15 Coercions; Chapter 16: Class Hierarchies; 16.1 Inheritance; 16.2 Objects; 16.3 Blessing Objects; 16.4 Constructor Arguments; 16.5 Base Class Initialization; 16.6 Construction and Destruction; 16.7 Automating Class Hierarchies; 16.8 Attribute Demolition; 16.9 Attribute Building; 16.10 Coercions; 16.11 Cumulative Methods; 16.12 Autoloading; Chapter 17: Modules; 17.1 Interfaces; 17.2 Refactoring; 17.3 Version Numbers; 17.4 Version Requirements; 17.5 Exporting; 17.6 Declarative Exporting; 17.7 Interface Variables; 17.8 Creating Modules; 17.9 The Standard Library; 17.10 CPAN; Chapter 18: Testing and Debugging; 18.1 Test Cases; 18.2 Modular Testing; 18.3 Test Suites; 18.4 Failure; 18.5 What to Test; 18.6 Debugging and Testing; 18.7 Strictures; 18.8 Warnings; 18.9 Correctness; 18.10 Overriding Strictures; 18.11 The Debugger; 18.12 Manual Debugging; 18.13 Semi-Automatic Debugging; Chapter 19: Miscellanea; 19.1 Revision Control; 19.2 Other Languages; 19.3 Configuration Files; 19.4 Formats; 19.5 Ties; 19.6 Cleverness; 19.7 Encapsulated Cleverness; 19.8 Benchmarking; 19.9 Memory; 19.10 Caching; 19.11 Memoization; 19.12 Caching for Optimization; 19.13 Profiling; 19.14 Enbugging; Essential Perl Best Practices; Perl Best Practices; , Code Layout; , Naming Conventions; , Values and Expressions; , Variables; , Control Structures; , Documentation; , Built-in Functions; , Subroutines; , I/O; , References; , Regular Expressions; , Error Handling; , Command-Line Processing; , Objects; , Class Hierarchies; , Modules; , Testing and Debugging; , Miscellanea; Editor Configurations; vim; vile; Emacs; BBEdit; TextWrangler; Recommended Modules and Utilities; Recommended Core Modules; Recommended CPAN Modules; Utility Subroutines; Bibliography; Perl Coding and Development Practices; General Coding and Development Practices; Colophon;
From the B&N Reads Blog

Customer Reviews