|
![]() |
This book kicks off with a compelling outline of the worthiness of best practices and the importance of adopting a coding standard, whatever that standard may be. Conway also defuses possible hurdles to the usefulness of the book by highlighting that the 256 guidelines are offered as (well reasoned) suggestions and should not be taken as dictats. Rather, they should be used to kick-start discussions for the creation, or review, of coding standards used by your team.
I also liked the supportive page given over to the problem of breaking old habits in pursuit of new coding practices.
I found that my progress through the book varied hugely. Guidelines where I was on top of the issue were swiftly consumed, while areas which offered new suggestions were poured over in a more considered manner. The sections which took the longest for me were those where I thought I was on top of the issue being addressed, yet turned out to be opening myself up to subtle unconsidered problems.
A short selection of guidelines which tickled me in various ways include;
- "Keep all user documentation in a single place within your source file."
- "When there is no 'obvious' scalar context return value, consider
Contextual::Return
instead." - "Always use the
/m
flag." - "Consider using
Regexp::Common
instead of writing you own regexes." - "Write test cases first."
Where relevant, Conway highlights the Perl internals which affect the guideline in question. For example, the guideline "Don't give subroutines the same name as built-in functions." cites the fact that "Perl considers some of its builtins to be 'more builtin' than others...".
I enjoy Conway's engaging and accessible writing style and the footnotes provided entertainment, as well as the birth of a new word (Necroselectomancy).
The appendices of the book offer very useful 'top 10' selections of guidelines for development, coding and module practices - followed by a simple list of all 256 guidelines offered in the book. These sections may prove helpful for those looking to short-list guidelines for inclusion in their coding standards.
Summary
Damian and all the other assisting engineers, whose real-world experiences back these guidelines, are to be thanked for the creation of a Perl book which will almost certainly improve the maintainability, robustness and efficiency of your perl code.
Buy this book!
Table of contents
Perl Best Practices Ch 1. Best Practices Ch 2. Code Layout Ch 3. Naming Conventions Ch 4. Values and Expressions Ch 5. Variables Ch 6. Control Structures Ch 7. Documentation Ch 8. Built-in Functions Ch 9. Subroutines Ch 10. I/O Ch 11. References Ch 12. Regular Expressions Ch 13. Error Handling Ch 14. Command-line Processing Ch 15. Objects Ch 16. Class Hierarchies Ch 17. Modules Ch 18. Testing and Debugging Ch 19. Miscellanea Appendix A. Essential Best Practices Appendix B. Perl Best Practices Appendix C. Editor Configurations Appendix D. Recommended Modules and Utilities Appendix E. Bibliography Index