Supplementary Slides for Software Engineering: A Practitioner's Approach, 5/e

Download Report

Transcript Supplementary Slides for Software Engineering: A Practitioner's Approach, 5/e

Supplementary Slides for
Software Engineering:
A Practitioner's Approach, 5/e
copyright © 1996, 2001
R.S. Pressman & Associates, Inc.
For University Use Only
May be reproduced ONLY for student use at the university level
when used in conjunction with Software Engineering: A Practitioner's Approach.
Any other reproduction or use is expressly prohibited.
This presentation, slides, or hardcopy may NOT be used for
short courses, industry seminars, or consulting purposes.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are
provided with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001
1
Slide 22
Chapter 20
Object-Oriented Concepts
and Principles
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are
provided with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001
2
Intro…
We live in the world of objects
OO approach first proposed in the late 1960s
Why OO?
• Reuse  faster dev & higher quality
• Inherently decoupled  Easier to maintain
 fewer side effect
• Easier to adapt & easier to scale
++
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are
provided with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001
3
The OO Process Model
Evolutionary process model
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are
provided with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001
4
The OO Mindset
objects
problem domain
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are
provided with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001
5
Key Concepts
• classes and class hierarchies
– instances
– inheritance
– abstraction and hiding
• objects
– attributes
– methods
– encapsulation
– polymorphism
• Messages [dest, operation, parameters]
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are
provided with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001
6
Classes
• object-oriented thinking begins with
the definition of a class often defined
as:
–
–
–
–
template
generalized description
pattern
“blueprint” ... describing a collection of
similar items
• a metaclass (also called a superclass)
is a collection of classes
• once a class of items is defined, a
specific instance of the class can be
defined
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are
provided with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001
7
Building a Class
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are
provided with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001
8
What is a Class?
occurrences
roles
organizational units
things
places
structures
external entities
class name
attributes:
operations:
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are
provided with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001
9
Examples
 Safehome software enables the homeowner to
configure the security system when it is installed,
monitors all sensors connected to the security system,
and interacts with the homeowner through a keypad
and function keys contained in the Safehome control
panel.
 During installation the Safehome control panel is used
to “program” and configure the system. Each sensor is
assigned a number and type, a master password is
programmed for arming and disarming the system, and
telephone number(s) are input for dialing when a
sensor event occurs.
…
++
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are
provided with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001
10
Potential Objects
Potential Object/Class
Homeowner
Sensor
Control panel
Installation
System
Number, type
Master password
Telephone number
Sensor event
…
++
General Classification
role or ext. entity
external entity
external entity
occurrence
things
not objects, attribute of system
things
things
occurrence
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are
provided with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001
11
Selection Characteristics
Retained information
Needed services: there is a set of operations
that can change the value of its attributes
Multiple attributes
Common attributes
Common operations
Essential requirements
By Coad and Yourdon
++
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are
provided with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001
12
Apply selection characteristics
++
Potential Object/Class
General Classification
Homeowner
Sensor
Control panel
Installation
System
Number, type
Master password
Telephone number
Sensor event
…
rejected: 1, 2 fail eventhough 6 applies
accepted
accepted
rejected
accepted
rejected: 3 fails
rejected: 3 fails
rejected: 3 fails
accepted
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are
provided with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001
13
Encapsulation/Hiding
The object encapsulates
both data and the logical
procedures required to
manipulate the data method
method
#2
#1
data
method
#6
method
#5
method
#4
Achieves “information hiding”
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are
provided with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001
14
Class Hierarchy
furniture (superclass)
table
chair
desk
"chable"
subclasses of the
furniture superclass
instances of chair
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are
provided with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001
15
Methods
(a.k.a. Operations, Services)
An executable procedure that is
encapsulated in a class and is designed
to operate on one or more data attributes
that are defined as part of the class.
A method is invoked
via message passing.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are
provided with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001
16
Messages
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are
provided with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001
17