next up previous contents
Next: Classes Up: Objects in Perl Previous: Objects in Perl

What are objects?

Basically you already know what an object is. Trust your instincts. The book you are reading is an object. The knife and fork you eat with are objects. In short, your life is filled with them.

The question that really needs to be asked is, "What are classes?" You see, all object-oriented techniques use classes to do the real work. A class is a combination of variables and functions designed to emulate an object. However, when referring to variables in a class, object-oriented folks use the term properties; and when referring to functions in a class, the term method is used.

I'm not sure why new terminology was developed for object-oriented programming. Because the terms are now commonplace in the object-oriented documentation and products, you need to learn and become comfortable with them in order to work efficiently.

In this chapter, you see how to represent objects in Perl using classes, methods, and properties. In addition, you look at the definitions of some big words such as abstraction, encapsulation, inheritance, and polymorphism.

Following are short definitions for these words. The sections that follow expand on these definitions and show some examples of their use.

Abstraction
-- Information about an object (its properties) can be accessed in a manner that isolates how data is stored from how it is accessed and used.
Encapsulation
-- The information about an object and functions that manipulate the information (its methods) are stored together.
Inheritance
-- Classes can inherit properties and methods from one or more parent classes.
Polymorphism
-- A child class can redefine a method already defined in the parent class.

next up previous contents
Next: Classes Up: Objects in Perl Previous: Objects in Perl
dave@cs.cf.ac.uk