As you begin to program with an object oriented language like Java,
the various concepts can all seem rather vague but then they start
to coalese and suddenly classes and objects all make sense. In the
meantime, we can try to get across the ideas with analoges and examples.
We can first present some metaphorical analogies to class definitions
and objects:
- Molds and Pots:
the class is the mold and the objects are the clay jars formed
by the mold.
- Templates and Plates: the
class is the template and the objects are the forms cut according
to the template.
- Stampers and labels: the
class is the ink stamper and the objects are the labels on the
papers.
(Note that we use the terms object and instance
interchangably.)
In the next section, we look at the
more concrete analogy of class/objects to types/data such as integer
and floating point types.
In the Chapter 3: Tech
section, we create a complex
number class and a histogram
class.
References & Web Resources
Latest update: Dec.13.2003
|