0% found this document useful (0 votes)
86 views

Object-Oriented Modeling and Design

The document discusses object-oriented analysis and design concepts like classes, objects, associations, and links. It provides examples and notation for modeling different types of associations between classes like one-to-one, one-to-many, and many-to-many.

Uploaded by

Raheel Butt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views

Object-Oriented Modeling and Design

The document discusses object-oriented analysis and design concepts like classes, objects, associations, and links. It provides examples and notation for modeling different types of associations between classes like one-to-one, one-to-many, and many-to-many.

Uploaded by

Raheel Butt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

Object-Oriented

Analysis and
Design
3 OBJECT
MODELING

Source: OBJECT-ORIENTED
MODELING A N D DESIGN
James Rumbaugh, Michael Blaha,
William Premerlani, Frederick Eddy,
William Lorensen

PAUL VOUGNY - EPITA 2008


1. OBJECTS A N D CLASSES

Two types of object diagrams :


- class diagram
- instance diagram

✘ CLASS DIAGRAM

Describes many possible instances of data.


It describes object classes.

✘ INSTANCE DIAGRAM

Describes how a particular set of objects relate to each other.


It describes object instances.
(Person) (Person)
Person (Person)
Joe Smith Mary Sharp

Class Objects
class diagram instance diagram

Person (Person) (Person)


name : string Joe Smith Mary Sharp
age : integer 24 52

Class with Attributes Objects with Values

Person Person Do not explicitly


person_ID : ID name : string
list object
name : string age : integer identifiers
age : integer

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.

Person File Geometric Object


name file_name color
features position
age size_in_bytes
of Person change_job move(delta : Vector)
last_update
change_address print select(p : Point) : Boolean
rotate(angle)

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

✘LINK : physical or conceptual connection between object instances. Instance of an


association.

✘ASSOCIATION : describes a group of links with common structure and common


semantics. Inherently bidirectionnal. Often implemented as pointers from one object
to another.

Pointer = attribute in one object that contains an explicit reference to another


object.

WARNING: associations as pointers means not modeling them.

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

(Country) Has_capital (City) INSTANC


France Paris E
DIAGRAM

(Country) Has_capital (City)


Senegal Dakar

link association and


object object link names are
optional
left to right if possible
zero-or-one
Workstation Window
console CAD:
multiplicity
COMPUTER-AIDED
DESIG
N
multiplicity symbols:
hollow ball (◦), solid ball (●) and "2+"

Line Point CLASS


name 2+ name DIAGRAM

(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

(Projet) (Language) Ternary


CAD Program C association
and links
diamond
3. ADVANCED LINK A N D ASSOCIATION
CONCEPTS
LINK ATTRIBUTES

Accessible by
File User

Link attribute for


access permission
a many-to-many
association
/etc/termcap (read) John Doe
/etc/termcap (read-write) Mary Brown
/usr/doe/.login (read- John Doe
write)
Works_for
Person Company
boss name name
social security no. address
Manages address salary
job title
worker
Link attributes for
a one-to-many
performance rating association

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

home directory association


as a class
Directory
ROLE NAMES

✘ A role is one end of an association.


A binary association has two roles, each of which may have a role name.

✘ A role name is a name that uniquely identifies one end of an association.

role

employee employer
Person Company
Works_for

employee employer Role names


Joe Doe Simplex for an
Mary Brown association
Jean Smith Simplex
United
Widget
s
Use of role names is optional, but it is often easier and less confusing to assign role
names instead of, or in addition to, association names.
Role names are necessary for associations between two objects of the same class.
owner
container
Person Company
Role names
for a directory authorized user
hierarchy contents

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.

Directory File Directory File


file name

Object class Qualifier Object class

one-to-one one-to-many

Qualification reduces the effective multiplicity of this association from one-to-many


to one-to-one. A directory has many files, each with a file unique name.
One way to find a file is to first find the directory and then traverse the file name
link. For instance, a directory provides the context for a file name.
Stock Stock
exchange exchange
Unqualified ticker symbol
and
qualified Lists
association Lists

Company
Company
ticker symbol

Unqualified Qualified

organization officer
Company office Person

ABC widgets President Roger Stick


Many-to-many
ABC Joe Embezzle
qualification
widgets Treasurer Joe Doe
ABC widgets Director Jane Doe
ABC Director Moe Brown
widgets Director Moe
ABC widgets President Brown
XYZ candy a set of related
Qualification partitions objects into disjoint subsets, but the subsets
may contain more than one object.
AGGREGATION

Aggregation is a tightly coupled form of association with some extra semantics.

Aggregation is:

✘ transitive: A part of B, B part of C ‹ A part of C.


✘ antisymetric: if A part of B, then B is not part of A.

Aggregation relationship ~ relating an assembly class to one component class. An


assembly with many kinds of components corresponds to many aggregation
relationships. We define each individual pairing as an aggregation so that we can
specify the multiplicity of each component within the assembly. This definition
emphasizes that aggregation is a special form of association.
Aggregation is drawn like association, except a small
diamond indicates the assembly end of the relationship.
Aggregation The figure shows a portion of an object model for a
word processing program. A document consists of many
paragraphs, each of which consists of many sentences.

Document Paragraph Sentence

Paragraphs cannot exist Sentences cannot exist


apart from a Document apart from a
Paragraph

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.

Generalization is sometimes called the IS A relationship because each instance of a


subclass is an instance of the superclass as well. The terms ancestor and
descendant refer to generalization of classes across multiple levels.

An instance of subclass is simultaneously an instance of all its ancestor classes. The


state of an instance includes a value for every attribute of every ancestor class. Any
operation on any ancestor class can be applied to an instance.
Equipement
name discriminator
Generalization manufacturer (optional part of a
weight generalization
cost relationship)

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

Centrifugal pump Diaphragm pump Plunger pump


impeller diameter diaphragm material plunger lenght
number of blades plunger diameter ...
axis of rotation number of cylinders
tank type

Spherical tank Pressured tank Floating roof tank


... diameter diameter
height
diameter
height
(Diaphragm pump) (Heat exchanger) (Floating roof tank)
name = P101 name = E302 name = T111
manuf = Simplex manuf = Brown manuf = Simplex
weight = 100 kg weight = 5000 kg weight = 10000 kg
cost = $5000 cost = $20000 cost = $50000
suct pres = 1.1 atm surface area = 300 m2 volume = 400000 liter
disch pres = 3.3 atm tube diameter = 2 cm pressure = 1.1 atm
flow rate = 300 l/hr diameter = 8 m
tube lenght = 6 m
dia matl = Teflon tube pres = 15 atm height = 9 m
shell pres = 1.7 atm

A multilevel
inheritance hierarchy
with instances

A discriminator is an attribute of enumeration type that indicates which property of


an object is being abstracted by a particular generalization relationship.
Only one property should be discriminated at once.
Discriminator values are inherently in one-to-one correspondence with the
subclasses of a generalization.
Figure In practise, whether or
color not a subclass is
center position "too deeply nested"
pen thickness depends upon judgment
Inheritance for
pen type
graphic
move
and the particular
figures details
select
rotate of a problem.
display

dimensionality

0 Dimensional 1 Dimensional 2 Dimensional


orientation orientation
fille type
scale scale
fill

Point Line Arc


endpoints radius Spline Polygon Circle
control pts num of sides diameter
start angle
arc angle vertices
display
display display display display display
rotate
USE OF GENERALIZATION

Generalization is a useful construct for both conceptual modeling and


implementation programming community. The terms inheritance, generalization,
and specialization all refer to aspects of the same idea and are often used
interchangeably.

✘Inheritance: mechanism of sharing attributes and operations using the


generalization relationship.

✘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.

✘Tightening the type of an attribute or operation argument to be a subclass of the


original type is a form of restriction and must be done with care.
5. GROUPING CONSTRUCTS

MODULE

✘A module is a logical construct for grouping classes, associations, and


generalizations.

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.

✘ Never more than one module per sheet.

✘ A sheet is just a notational convenience, not a logical construct.

✘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

Text Scrolling Button Choice Text


window canvas Line Closed string Item Item
string x1 shape depressed max length
insert x2 fill color current string
delete fill pattern {subset}
y1
current
vertices choices
Point y2 Polygon
{ordered} Ellipse choice
Choice entry Object model
x draw x string of a
y
y value windowing
draw system
a

You might also like