Chapter 1: Structure

When you create a class there are certain things that you need to have; you might recall talking about properties and methods. Properties are the variables/data that describe an object and methods are the functions/actions that show what that object can do.

Before we get too much further we need to establish (or perhaps reinforce) what the difference is between a class and an object. A class is a template describing what sort of things a particular thing could have. For example, if you think of a drinking glass, it would have a material, a color, a weight, a volume, etc. Also it could be filled, it could be emptied, it could be broken, etc. These are a sample of the properties and methods a DrinkingGlass class might have. We can definitely get a general idea of what we’re talking about, but we haven’t actually given any specifics! Perhaps I’m thinking of an entirely different particular glass than you are. That’s why this is just a class…no specifics are given for anything in particular.

An object, though, is all of the specific information that describes a single thing. I’m thinking of a clear, glass, 8 fluid ounce, DrinkingGlass. Now we might be able to each picture the exact same thing. (That’s not enough details yet for them to be exact necessarily, but hopefully you get the idea.) An object is a specific instance of a class with the details filled in. We can’t interact with a class because it’s really just an idea or generalization, but we CAN interact with an object since we have one in mind.

In the next sections we are going to explore the ins and outs of classes and objects and really get a better understanding of how we should go about creating them.


← Previous PageNext Page →