Classes, Properties, and Methods

Object-oriented programming comes with its own set of jargon. You will have to learn a little bit of it to keep up, but only a little.

The most basic concept in OOP is the class. A class is simply a generic description of something. In real life cars, apples, and cats are all types of classes. Not all cats are the same, but conceptually there's such a thing as a “generic cat”: mammal, quadruped, carnivore, small ears, long tails, and they sleep a lot. OOP also has the concept of a subclass, which is a more refined concept of the generic class—like a housecat, felis cattus.

The next two terms go together: an object is an instance of the class. If I wanted a concrete, physical example of something from the housecat ...

Get SAMS Teach Yourself Perl in 24 Hours THIRD EDITION 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.