Object-Oriented programming follows the same goals that we discussed when introducing functions, principally to make reusing code easier. It uses classes to group functions and variables together as an object. It may help to think of objects as little black boxes that can do work without you knowing exactly how it's done.
They still use functions, but they get a new name when defined in classes. They're called methods. The class works as a blue print for creating objects of that type. Variables can still be defined in methods, but they gain the new ability to be defined as part of the class itself.
When a new object is created from a class, it is called an instance of that class. Any variables that are defined in the class get separate storage space in each instance. The separate storage for variables provides the instance of an object with the ability to remember information between method executions. Figure 5-3 demonstrates the relationship between a class and its components.
Figure 5-3. A class can contain methods and attributes (variables)
If you're new to the concepts of OO programming, don't worry about understanding everything right away. We'll work with a class in Chapter 7, so it's good enough just to know how to call the methods. In fact, anything that can be done with objects can be done with plain functions. It's just a matter of style and ...