Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Introduction to
Object-Oriented
Programming and
Software
Development
Chapter 1 - 1
Objectives
After you have read and studied this chapter, you
should be able to
Name the basic components of object-oriented programming
Differentiate classes and objects.
Differentiate class and instance methods.
Differentiate class and instance data values.
Draw program diagrams using icons for classes and objects
Describe significance of inheritance in object-oriented programs
Name and explain the stages of the software lifecycle
Chapter 1 - 2
Chapter 1 - 3
Chapter 1 - 4
Chapter 1 - 5
<Class Name>
Example:
Account
We
Weuse
useaarectangle
rectangleto
to
represent
a
class
with
represent a class with
its
itsname
nameappearing
appearing
inside
the
inside therectangle.
rectangle.
Motorcycle
Chapter 1 - 6
<Object Name>
We
Weuse
useaarectangle
rectangleto
to
represent
an
object
represent an objectand
and
place
the
underlined
place the underlined
name
nameof
ofthe
theobject
object
inside
the
rectangle.
inside the rectangle.
Example:
SV198
This
Thisisisan
anobject
objectnamed
named
SV198.
SV198.
Chapter 1 - 7
This
Thisnotation
notationindicates
indicates
the
class
which
the class whichthe
the
object
is
an
instance.
object is an instance.
Example:
SV198 : BankAccount
This
Thistells
tellsan
anobject
object
SV198
is
an
instance
SV198 is an instanceof
of
the
BankAccount
class.
the BankAccount class.
Chapter 1 - 8
Chapter 1 - 9
Sending a Message
Message
Messagedeposit
depositwith
with
the
argument
250.00
the argument 250.00isis
sent
sentto
toaaBankAccount
BankAccount
object
SV198.
object SV198.
deposit 250.00
SV198 : BankAccount
Chapter 1 - 10
Ask
Askfor
forthe
thecurrent
current
balance
of
this
balance of this
particular
particularaccount.
account.
getCurrentBalance()
SV198 : BankAccount
current balance
The
Thecurrent
currentbalance
balanceof
of
SV198
is
returned.
SV198 is returned.
The McGraw-Hill Companies, Inc. Permission
required for reproduction or display.
Chapter 1 - 11
MobileRobot
getMaximumSpeed()
maximum speed
Chapter 1 - 12
Chapter 1 - 13
SV129 : BankAccount
SV098 : BankAccount
SV211 : BankAccount
current balance
908.55
current balance
1304.98
current balance
All
Allthree
threeBankAccount
BankAccount
objects
possess
objects possessthe
the
same
instance
data
same instance data
value
valuecurrent
currentbalance.
balance.
354.00
The
Theactual
actualdollar
dollar
amounts
are,
amounts are,of
ofcourse,
course,
different.
different.
Chapter 1 - 14
There
Thereisisone
onecopy
copyofof
minimum
minimumbalance
balancefor
for
the
whole
class
and
the whole class and
shared
sharedby
byall
allinstances.
instances.
This
Thisline
lineisisan
an
instance-of
instance-of
relationship.
relationship.
SV129 : BankAccount
SV098 : BankAccount
SV211 : BankAccount
current balance
908.55
current balance
1304.98
current balance
354.00
Chapter 1 - 15
SV129 : BankAccount
minimum balance
100.00
current balance
908.55
When
Whenthe
theclass
classicon
iconisis
not
notshown,
shown,we
weinclude
include
the
class
data
value
the class data valueinin
the
theobject
objecticon
iconitself.
itself.
Chapter 1 - 16
Inheritance
Inheritance is a mechanism in OOP to design two
or more entities that are different but share many
common features.
Features common to all classes are defined in the
superclass.
The classes that inherit common features from the
superclass are called subclasses.
We also call the superclass an ancestor and the subclass a
descendant.
Chapter 1 - 17
A Sample Inheritance
Here are the superclass Account and its
subclasses Savings and Checking.
Account
Checking
Savings
Chapter 1 - 18
Inheritance Hierarchy
An example of inheritance hierarchy among
different types of students.
Student
Graduate
Masters
Doctoral
Undergrad
Law
Commuting
Resident
Chapter 1 - 19
Software Engineering
Much like building a skyscraper, we need a
disciplined approach in developing complex
software applications.
Software engineering is the application of a
systematic and disciplined approach to the
development, testing, and maintenance of a
program.
In this class, we will learn how to apply sound
software engineering principles when we develop
sample programs.
The McGraw-Hill Companies, Inc. Permission
required for reproduction or display.
Chapter 1 - 20
Analysis
Design
Coding
Testing
Operation and Maintenance
Chapter 1 - 21