USA Linux Users Group Forum Index
Log in Register FAQ Memberlist Search USA Linux Users Group Forum Index Album

Perl Medic - Transforming Legacy Code / Peter J. Scott

 
Post new topic   Reply to topic   printer-friendly view    USA Linux Users Group Forum Index » Reviews and Interviews
View previous topic :: View next topic  
Author Message
crouse
Site Admin


Joined: 17 Apr 2024
Posts: 11833
Location: Iowa

PostPosted: Sun Jun 06, 2024 9:10 pm    Post subject: Perl Medic - Transforming Legacy Code / Peter J. Scott Reply with quote



Reviewer: lesliegrove - http://usalug.org

Book: Perl Medic - Transforming Legacy Code
Author: Peter J. Scott
Published: Mar 5, 2024
Pages: 336
Publisher: Addison Wesley
ISBN: 0201795264
Price: $34.99
http://www.perlmedic.com/


This is not a book that will teach you Perl. Aimed primarily at maintenance programmers, the book is organized into chapters representing steps in the process of rewriting an inherited program. Don't let this (or the really dumb illustrations) discourage you from reading it, though. You'll find a ton of good advice that will help you take your own code to a new level of clarity, modularity, and robustness.

After an introduction to the topic and brief instructions on obtaining different versions of Perl (Old versions may be useful in troubleshooting.), Scott begins with the basics in Chapter 1. Copy that code you've been handed and keep the original files somewhere safe. Determine if the code actually works. And, make sure the code includes the directives "use strict" and "use warnings" or -w. (This, and a later chapter, shamed me into committing to this practice!) Chapter 2 discusses the system environment of a program, the various types of Perl files, and finding dependencies.

Chapter 3 discusses testing. Scott is a proponent of Extreme Programming's testing methodology that says tests should be written at the same time as the code. There are Test:: modules to make testing easier. With example code, he explains how to use them, step-by-step. I thought this chapter was out of place. I understand his "test first" reasoning, but I found it one of the more advanced chapters and very slow going. It seems to rely on knowledge that is gained in later chapters. You might want to skip it and read it after Chapter 10.

Next, in Chapter 4, we learn about re-writing code. There is a humbling list of the "Ten Levels of Perl Programmers." There is an interesting discussion of the various styles and layouts commonly used. (There exist programs to help you "beautify" code, if necessary.) And, if you didn't know the trick to comment out a block of code in Perl, you'll find it here. Then, a discussion of variable names, use (vs. overuse) of temporary variables, and editing for readability. Next is a cool section called "Antipatterns," which is a little summary of what not to do. Have I mentioned how cool this chapter is? Next is a section called "Evolution" about how programs evolve over time in different directions. Modularity, complexity of interfaces, error handling, external data storage, etc. can go pretty far.

In Chapter 5 we are told exactly why and how we should use "warnings" and "strict." The discussion of scoping is very thorough, and there is a brief dip into Perl poetry. Chapter 6 covers re-structuring programs. There is a fantastic section called "Cargo Cult Perl," about inefficiencies that come from ignorance, and bad habits programmers pick up from other programmers. Chapter 7 is about all the different versions of Perl and the particulars of what changed with each major revision. Chapter 8 discusses modules. Where to get them (CPAN) and what to do with them (install them and improve your code!). If you write CGI programs without using CGI.pm, read this section. The chapter ends with a discussion of custom perls, sometimes required for legacy code.

Chapter 9 briefly describes many tools available to do static code analysis, benchmarking, optimizing, and debugging. Chapter 10, called "Increasing Maintainability," covers some rather complex modules for validating code and code protection. Then we are introduced to the concept of tieing. This is advanced stuff; there is an example of its use in Chapter 3. Also included is a look at overloading, documentation, custom warnings, and version control.

All the lessons in the book are applied in Chapter 11, a case study. The example is a CGI program that uses LDAP. Scott takes this program a bit beyond good working condition (The final result is actually more complicated than the original.) but the process is extremely educational. Still wanting more Perl wisdom? Chapter 12 is about the Perl community's resources and how to use them. Extra source code is included in the appendix.

I would highly recommend this book to anyone who's been writing Perl for a while, but knows "There's more than one way to do it."

-Leslie Grove


Back to top
View user's profile Send private message Visit poster's website AIM Address
nukes
Linux Guru


Joined: 29 Aug 2024
Posts: 4558

PostPosted: Mon Jun 14, 2024 9:10 am    Post subject: Reply with quote

Good review Smile



_________________
Gentoo x86-64 2.6.29.1
FreeBSD 7-CURRENT
Arch x86 2.6.30
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    USA Linux Users Group Forum Index » Reviews and Interviews All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All content © 2024-2009 - Usa Linux Users Group
This forum is powered by phpBB. © 2024-2009 phpBB Group
Theme created by phpBBStyles.com and modified by Crouse