App01 PDF
App01 PDF
Basic Characteristics of
Object-Oriented Systems
Patient
name
address
birthdate
phone
insurance carrier
+make appointment()
+calculate last visit()
+change status()
+provides medical history()
+create()
attributes (or methods) that deal with issues related to all instances of the class. For example,
to create a new patient object, a message is sent to the Patient class to create a new instance
of itself. However, from a systems analysis and design point of view, we will focus primarily
on attributes and methods of objects and not of classes.
Patient
name
address
create
birthdate
phone
insurance carrier aPatient
Come up with a set of examples of using encapsulation this information? What about personal information that
and information hiding in everyday life. For example, is you would prefer to be private? How would you prevent
there any information about yourself that you would not someone from retrieving it?
mind if everyone knew? How would someone retrieve
INHERITANCE
Inheritance, as an information systems development characteristic, was proposed in data
modeling in the late 1970s and the early 1980s. The data modeling literature suggests using
inheritance to identify higher-level, or more general, classes of objects. Common sets of
attributes and methods can be organized into superclasses. Typically, classes are arranged in
a hierarchy, whereby the superclasses, or general classes, are at the top, and the subclasses, or
specific classes, are at the bottom. In Figure A1-3, person is a superclass to the classes Doc-
tor and Patient. Doctor, in turn, is a superclass to General Practitioner and Specialist. Notice
how a class (e.g., Doctor) can serve as a superclass and subclass concurrently. The relation-
ship between the class and its superclass is known as the a-kind-of relationship. For example
in Figure A1-3, a General Practitioner is a-kind-of Doctor, which is a-kind-of Person.
Subclasses inherit the appropriate attributes and methods from the superclasses above
them. That is, each subclass contains attributes and methods from its parent superclass.
4 Appendix 1 Basic Characteristics of Object-Oriented Systems
Person
Abstract Classes
Doctor Patient
FIGURE A1-3
General Practitioner Specialist
Class Hierarchy
with Abstract and Concrete Classes
Concrete Classes
For example, Figure A1-3 shows that both Doctor and Patient are subclasses of Person and,
therefore, will inherit the attributes and methods of the Person class. Inheritance makes it
simpler to define classes. Instead of repeating the attributes and methods in the Doctor and
Patient classes separately, the attributes and methods that are common to both are placed
in the Person class and inherited by those classes below it. Notice how much more efficient
inheritance hierarchies of object classes are than the same objects without an inheritance
hierarchy (see Figure A1-4).
Most classes throughout a hierarchy will lead to instances; any class that has instances
is called a concrete class. For example, if Mary Wilson and Jim Maloney were instances of
the Patient class, Patient would be considered a concrete class. Some classes do not produce
Patient Person
name name
address address
birthdate birthdate
phone phone
insurance carrier
+updateBirthDate()
+updateBirthDate()
+updateInsuranceCarrier()
VS.
Doctor
name
address
birthdate Patient Doctor
phone insurance carrier MedicalSchoolSpecialty
MedicalSchoolSpecialty
+updateBirthDate() +updateBirthDate()
+updateBirthDate() +updateInsuranceCarrier()
+updateMedicalSchoolSpecialty() +updateMedicalSchoolSpecialty()
See if you can come up with at least three different inheritance hierarchy using the class. Which of the classes
classes that you might find in a typical business situation. are abstract, if any, and which ones are concrete?
Select one of the classes and create at least a three-level
instances because they are used merely as templates for other more specific classes (espe-
cially those classes located high up in a hierarchy). The classes are referred to as abstract
classes. Person is an example of an abstract class. Instead of creating objects from Person,
we create instances representing the more specific classes of Doctor and Patient, both types
of Person (see Figure A1-3). What kind of class is the General Practitioner class? Why?
aSquare
lf
urse
Yo
w
ra
D
DrawYourself aCircle
D
ra
w
Yo
anArtist
ur
se
l
f
aTriangle
FIGURE A1-5
Polymorphism
6 Appendix 1 Basic Characteristics of Object-Oriented Systems
Can you think of any way in which you use polymor- does? Do you always perform the task the same way or
phism and/or dynamic binding in your everyday life? For does the method of performance depend on where you
example, when you are told to do some task, do you are when you perform the task?
always perform the task like everyone else you know
languages we find complicated decision logic based on the different types of objects in a
system. For example, in a traditional programming language, instead of sending the mes-
sage Draw yourself to the different types of graphical objects in Figure A1-5, we would have
to write decision logic using a case statement or a set of if statements to determine what
kind of graphical object we wanted to draw, and we would have to name each draw function
differently (e.g., draw square, draw circle, or draw triangle). This obviously would make the
system much more complicated and more difficult to understand.
KEY TERMS
Abstract classes Encapsulation Object
A-kind-of Information hiding Polymorphism
Attribute Inherit State
Behavior Inheritance Static binding
Class Instance Subclass
Concrete classes Message Superclass
Dynamic binding Method
QUESTIONS
1. What is the difference between classes and objects? 4. What is meant by polymorphism when applied to
2. What are methods and messages? object-oriented systems?
3. Why are encapsulation and information hiding impor- 5. Compare and contrast dynamic and static binding.
tant characteristics of object-oriented systems?
EXERCISES
A. Using your favorite Web search engine, find alterna- port students in finding an appropriate apartment to
tive descriptions of the basic characteristics of object- live in next semester. What are the different types of
oriented systems. objects (i.e., classes) you would want to include in
B. Look up object-oriented programming in Wikipedia. your system? What attributes or methods would you
Write a short report based on its entry. want to include in their definition? Is it possible to
C. Choose an object-oriented programming language, arrange them into an inheritance hierarchy? If so, do
such as C, Java, Smalltalk, or VB.Net, and use the it. If not, why not?
Web to find out how the language supports the basic E. Create an inheritance hierarchy that could be used to
characteristics of object-oriented systems. represent the following classes: accountant, customer,
D. Assume that you have been assigned the task to create department, employee, manager, organization, and
an object-oriented system that could be used to sup- salesperson.