CaFe.pm - Perl Mongers de Capital Federal
http://cafe.pm.org/


Review of "Perl Objects, References & Modules"

by Walter Marcelo Lamagna (wlamagna (at) hotmail.com)


Autor: Randal L. Schwartz with Tom Phoenix
Editorial: O' Reilly
ISBN: 0-596-00478-8



Introduction


Perl gives a complete solution to the object oriented programming methodology, it is not easy for the beginner and may be intimidating, it is recommended for the advanced programmer that wants to use Objects in Perl, create and maintain existing Object Oriented programms.

It is very recommended to read this book from beginning to end without jumping chapters because every chapter presents better ways to do previously explained code.

Chapter 1 - Introduction

It is recommended to read before "Learning Perl" or the Llama book.


Chapter 2 - Building Larger Programs

Here are explained the packages, method to include them and how to divide the program in parts using "do".


Chapter 3 - Introduction to References

References clarified, explained with many examples are References to Array and Hashes.


Chapter 4 - References and Scoping

More examples on how to use references and how to manage anonymous data structures.


Chapter 5 - Manipulating Complex Data Structures

Teaches how to use the debugger to examine complex data structures using Data::Dumper and how to read the output of the debugger into a program with Storable module.


Chapter 6 - Subroutine References

All is well organized, after explaining an introduction to references it is explained References to Subroutines (coderef). Like with anonymous data structures, you can create anonymous subroutines with Perl and returning subroutines from other subroutines.


Chapter 7 - Practical Reference Tricks

At this point you will learn about the sorting efficiently strategies and how to optimize the task with the "sort" operator.


Chapter 8 - Introduction to Objects

It begins from the most basic classes, describing advanced use of classes and difference between -> and :: in method invocation.
The use of @ISA variable and SUPER (for Super Classes) word for inheritance, methods overriding in classes.
Very good explained how to reuse code, step by step


Chapter 9 - Objects with Data

Explains the "bless" operator, creates objects, instance of classes and how they work in simple examples with many member variables. You understand object constructors, differences between using Classes or Objects and how you implement encapsulation.


Chapter 10 - Object Destruction

It is important to know when an object gets destroyed because you would need to take cleanup actions, for that exists the DESTROY method that is automatically called when the Object dies.

It begins with simple examples and goes to Nested Object Destruction, the %REGISTRY variable and instructive examples to analyze.


Chapter 11 - Some Advanced Object Topics

Use of UNIVERSAL class, the class from which all objects are derived, its "isa" method (test if the class is a member of a given class) and "can" methods (test if the class has a specified method) available in all the objects:

$object->isa("Animal")
$object->can("printname")

This chapter also presents the AUTOLOAD method, explains the use of Class::MethodMaker CPAN module, Multiple Inheritance.


Chapter 12 - Using Modules

This chapter explains how to use and write our own modules.


Chapter 13 - Writing a Distribution

Creating a distribution is what you need if you want to incorporate in your module installation information, documentation, know if there are missing files needed by the module, testing features and verify the correct operation of the module (make test) and c language interfaces.


Chapter 14 - Essential Testing

What to test ? How to test ? Randal gives an introduction to testing the perl modules we create and how to use Test::Simple or Test::More modules.


Chapter 15 - Contributing to CPAN

If you create a new module and do want to share it with the world to help others with your creation, what you need is CPAN, the Comprehensive Perl Archive Network. You will learn how to prepare your distribution, upload, announce and get it tested by other developers in all kind of platforms.