Object-Oriented Modeling and Design
Object-Oriented Modeling and Design
Analysis and
Design
3 OBJECT
MODELING
Source: OBJECT-ORIENTED
MODELING A N D DESIGN
James Rumbaugh, Michael Blaha,
William Premerlani, Frederick Eddy,
William Lorensen
✘ CLASS DIAGRAM
✘ INSTANCE DIAGRAM
Class Objects
class diagram instance diagram
Wrong Correct
A method (body) is the implentation of an operation (prototype, signature) for a
class. Several methods may be refered by a generic operation. However, each
method may be implemented by a different piece of code.
Operations
Class_Name
attribute_name : data_type = default_value Object
... modeling
operation_name(argument_list) : result_type notation for
... classes
2. LINK A N D ASSOCIATIONS
Each association in the class diagram corresponds to a set of links in the instance
diagram, just as each class corresponds to a set of objects.
association
Has_capital
Country City CLASS
DIAGRAM
name name
class class
One-to-one
(Country) Has_capital (City)
association
Canada Ottawa
and links
(Line)
L1 L2
(Line) (Point)
L2 P1 L3
P1 P2
(Line) INSTANC L1
L3 (Point) E
P2 L4
DIAGRAM
(Line)
L4 L5
Many-to-many
(Line) association SAMPLE
L5 and links DATA
Projet Language
CLASS
DIAGRAM
Person
atomic unit
(Projet) (Language)
accounting system Cobol
(Person) INSTANC
Mary E
DIAGRAM
Accessible by
File User
Team
Pitcher Year
Link
wins attributes
losses W L for a ternary
association
Harry Eisenstat Cleveland Indians 1939 6 7
Harry Eisenstat Detroit Tigers 1939 2 2
Willis Hudin Cleveland Indians 1939 9 10
Willis Hudin Cleveland Indians 1940 2 1
Willis Hudin Washington Senators 1940 1 2
Willis Hudin St.Louis Brows 1940 0 1
Works_for
Company Person
name name Prefered
social security no. form
address
salary address
job title
Link attribute
versus
object
attribute
Works_for
Company Person
name name Discouraged
social security no. form
address
address
salary
job title
MODELING AN ASSOCIATION AS CLASS
Authorized on
User Workstation
Authorization
priority
privileges
start session
Modeling an
role
employee employer
Person Company
Works_for
ORDERING
Ordered
Special kind sets in an
of association
constraint
{ordered}
Window Screen
Visible_on
QUALIFICATION
A qualified association relates two object classes and a qualifier. The qualifier is a
special attribute that reduces the effective multiplicity of an association. One-to-
many and many-to-many associations may be qualified.
one-to-one one-to-many
Company
Company
ticker symbol
Unqualified Qualified
organization officer
Company office Person
Aggregation is:
Microcomputer
System
Monitor Mouse Keyboard Multilevel
box
Aggregation
CPU
Chasing RAM FAN
4. GENERALIZATION A N D INHERITANCE
GENERAL CONCEPTS
Generalization and inheritance are powerful abstractions for sharing similarities
among classes while preserving their differences.
Each subclass is said to inherit the features of its superclass.
equipement type
Specialization
Pump Heat exchanger Tank
suction pressure
discharge pressure
surface area
tube diameter
... volume
pressure
flow rate tube lenght
tube pressure
shell
pump type pressure
A multilevel
inheritance hierarchy
with instances
dimensionality
✘Generalization: derives from the fact that the superclass generates the
subclasses.
✘Specialization: refers to the fact that the subclasses refine or specialize the
superclass.
OVERRIDING FEATURES
✘A subclass may override a superclass feature by defining a feature with the same
name. The overriding feature (subclass) refines and replaces the overriden feature
(superclass).
✘An override should preserve attribute type, number, and type of arguments to an
operation and operation return type. We should never override the signature, or
form, of a feature.
MODULE
SHEET
✘A sheet is the mechanism for breaking a large object model down into a series of
pages. Each module consists of one or more sheets.
✘Multiple copies of the same class form the bridge for connecting sheets in an
object model.
6. A SAMPLE OBJECT MODEL Window
Canvas x1
cx1 Panel x2
cx2 y1
Scrolling y2
window item name
display
x-offset cy1 undisplay
y-offset add-element raise
scroll delete-element
cy2 Panel lower
window Item
element x Event
Shape y notify action
color label
line width event keyboard
event