Information Technology Reference
In-Depth Information
with common attributes. This definition is a direct result of the previous definition:
objects created using a class will be distinct from each other, but will share the
characteristics given to them by that class, and will therefore constitute a group of
similar objects. These characteristics include not only the objects' attributes, but
also their methods and interfaces, all as defined by the instantiating class.
2.2.2 The Class-Object Hierarchy
We often describe classes and objects in terms of real-world concepts. Fortunately,
though, some of the controversies of the real-world do not carry over into the field
of software engineering. There is no chicken-egg controversy in object-oriented
programming. The class comes first. As we have said, classes are essentially the
blueprints or templates behind objects. In our definition from Sect. 2.1 , the
monster truck object could not exist without the truck class that it is derived
from. An object is an instance of a certain class, and for that reason a class must be
defined before the object can even be conceived. Once a class has been defined, an
object of that type can be created from it, using the constructor method specified in
that class. This action of creating an object from a class is instantiation, and the
class used to create the object is referred to as the instantiating class. A single
class may be used to instantiate any number of objects. All of these objects are
then referred to as members of the instantiating class.
2.2.3 Why Use Objects and Classes?
We have said a good deal about what objects and classes are, how they related, and
what they are capable of doing. However, object-oriented programming only
represents one line of thought in the world of computer programming. Why should
we use this paradigm? The next sections will describe the key features and
advantages of the object-oriented paradigm as afforded by the use of objects and
classes.
2.3 Modularity
The move from the classical structured programming model to the modern object-
oriented paradigm represented a fundamental shift in the practice of software
engineering. One portion of this shift dealt with the conceptualization, organiza-
tion, and management of a software. If a large software engineering project is
attacked as a single program to be written, the resulting code will undoubtedly be
cumbersome, arduous to navigate, and extremely difficult to debug. As a solution
Search WWH ::




Custom Search