Chapter 7. Object-Oriented Programming

There was a child went forth every day,And the first object he look’d upon, that object he became.

Walt Whitman, There Was a Child Went Forth

Object orientation (OO) is the latest software methodology to occupy the airwaves, hyped to a point where the term “object-oriented design” seems to automatically imply a good design. In this chapter, we will study what the noise is all about and build objects using Perl. I will leave it to the plethora of OO literature to convince you that there is a respectable middle-ground and that the object revolution is indeed a good thing.

If you are already conversant with OO, you could simply read the “Objects” section in Appendix B. Among other things, it supplies a C++ example and translates it to equivalent Perl code.

OO: An Introduction

Fred Brooks, in his classic The Mythical Man-Month [Section 7.6], says:

The programmer at wit’s end for lack of space can often do best by disentangling himself from his code, rearing back, and contemplating his data. Representation is the essence of programming.

He was talking about space reduction, but it is nevertheless sage advice.

Complex systems are inherently hierarchical, and many abstractions and methodologies have been invented to take advantage of this aspect. Until the late seventies, functional decomposition (top-down design) held sway as the definitive method to understand and implement complex systems. A developer would begin by writing high-level pseudo-code ...

Get Advanced Perl Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.