Software Design Methodologies: UML in Action

27
May-June 2001 ISISTAN Research Institute – Tandil, Argentina Software Design Methodologies: UML in Action Dr. Mohamed Fayad, J.D. Edwards Professor Department of Computer Science & Engineering University of Nebraska, Lincoln Ferguson Hall, P.O. Box 880115 Lincoln, NE 68588-0115 http://www.cse.unl.edu/~fayad

description

Software Design Methodologies: UML in Action. Dr. Mohamed Fayad, J.D. Edwards Professor Department of Computer Science & Engineering University of Nebraska, Lincoln Ferguson Hall, P.O. Box 880115 Lincoln, NE 68588-0115 http://www.cse.unl.edu/~fayad. Lesson 11: Object-Oriented - PowerPoint PPT Presentation

Transcript of Software Design Methodologies: UML in Action

Page 1: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina

Software Design Methodologies: UML in Action

Dr. Mohamed Fayad, J.D. Edwards Professor

Department of Computer Science & Engineering

University of Nebraska, Lincoln

Ferguson Hall, P.O. Box 880115

Lincoln, NE 68588-0115

http://www.cse.unl.edu/~fayad

Page 2: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S2 OO Concepts -2

2

Lesson 11:Object-Oriented

Concepts -2

Page 3: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S3 OO Concepts -2

Lesson Objectives

Objectives

3

Review of previous lecture Discuss associations Explore recursive associations, attributed association Understand association constraints Understand qualified & derived associations Discuss UML – aggregation

Page 4: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S4 OO Concepts -2

An association shows a two-way relationship between

objects (instances) of two or more classes and requiring

special implementation to ensure integrity.

A particular instance of an association is often called a link.

Associations between classes are required if the objects

need to communicate.

Associations are often named, and have role-names for

each side of the link.

11

Associations

Page 5: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S5 OO Concepts -2

5

More on Associations

Association Name

Person

nameageaddress

Car

modelyear# of doors

registeredCar owner

Vehicle Registration

Roles Names

Page 6: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S6 OO Concepts -2

Simple example:

An association has a name and a numerical specification (multiplicity indication) of how many objects on one side of the association are connected with how many objects on the other side.

Associations are called use relationships – even if this may seem somewhat cheeky in the example below

6

More on Associations

Window GeomFiguredisplays 0..*

Company Personemploys 0..*

Employer Employee

Page 7: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S7 OO Concepts -2

Associations are directed (one way), bidirectional, and undirected.

UML makes no distinction between bidirectional and undirected associations.

7

More on Associations

Class1 Class2

StereotypeRelationName{Constraints} *

role1 Role2: interface

Multiplicity

1

Page 8: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S8 OO Concepts -2

Recursive association: A class has a relation with itself.

It is also possible to model associations that are valid only temporarily “stereotype or temporary”

Constraints may be used to restrict the relation under specific aspects.

A role name describes how the object is seen by the opposite object in the association.

An association can be described in more detail by means of constraints, tagged values, and stereotypes.

Stereotypes are noted before or above the relation name, constraints, and tagged values after or below the name. 8

More on Associations

Page 9: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S9 OO Concepts -2

Directed association is a one-way association, in which one side knows the other, but not vice versa.

Multiplicity Specification:

– 1 exactly one

– 0, 1 zero or one

– 0..4 between zero and four

– 3, 7 either three or seven

9

More on Associations

Page 10: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S10 OO Concepts -2

More multiplicity specifications:

– 0..* greater than or equal to zero (default)

– * ditto

– 1..* greater than or equal to one

– 0..3, 7, 9..* between zero and three, or exactly seven, or greater than or equal to nine.

10

More on Associations

Page 11: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S11 OO Concepts -2

Recursive associations are associations in which one class is involved.

11

More on Associations

Employee

namestaffNoroomNo

Person

Patient

1manager

reports to

leads

office clerk

has

* *relative

Page 12: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S12 OO Concepts -2

An n-ary association is like a common (binary) association, except that more than two association roles involved in it.

12

N-ary Association

Class1 Class2

Class3

N-aryassociation

Ternaryassociation

Page 13: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S13 OO Concepts -2

13

More on n-ary Association

datetrainNo

TraincarriageNo

seatNo

Seat

nametitle

Passenger

Reservation

1 1..*

1..*

Ternaryassociation

Page 14: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S14 OO Concepts -2

14

More on Associations• Recursive Associations• N-ary Associations• Attributed Associations (Association Class)• Association Constraints• Qualified Associations• Derived Associations• Directed Associations• Ordered Associations• Realization/Refinements• Dependency

Page 15: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S15 OO Concepts -2

More on Associations

Associations are usually bidirectional

Allows each object involved in the relationship

to refer to the object to which it is related.

Bidirectional association means at the

relationship has an inverse.

Associations do not have to be bidirectional. 15

Page 16: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S16 OO Concepts -2

Man WomanMarriage

husband wife

Screen WindowWindows

Nets UserAuthorization

Car Trailer

Association Type

One-to-One

One-to-Many(One-to-Zero-or-More)

Many-to-Many

Zero or One 16

Page 17: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S17 OO Concepts -2

Square LineSides

father mother

children

Secure Room PersonOccupants

Male FemaleTraditionalFamily

Association Type

Specified the # of instances on the “many” side

Specify the possible # ofinstances using “or”

Ternary relationship

Child 17

Page 18: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S18 OO Concepts -2

Server Client

Connection

baudRateprotocolwireType

disconnectrerouteLink

• These attributes don’t belongin either the Client or Serverclass.• They are attributes of the connection itself.

• The association class can have behaviors as well as attributes.

Connection

Association Class

18

Page 19: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S19 OO Concepts -2

Aggregation is a special form of association.

Aggregation is used when the relationship is

“part/whole” or “contains/is-part-of”

Aggregation is transitive and operations on

“whole” often cascade down to “parts”.

19

Aggregation & Composite

Page 20: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S20 OO Concepts -2

20

Aggregation & Composite

Server

Client

Aggregation

52

“whole”

“part”

Computer

CPU Disk Drive Keyboard Mouse

*

Page 21: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S21 OO Concepts -2

Special diamond symbol used on “whole” side to indicate

aggregation.

Aggregation is an anti-symmetric that is, if A is part of B, then B is not

part of A.

DO NOT confuse aggregation with generalization

An essential property of aggregates is that the whole acts as a proxy

for its parts.

A composition is a strict form of aggregation, in which the parts are

existence-dependent on the entirely

21

Aggregation & Composite

Page 22: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S22 OO Concepts -2

22

Aggregation & Composite

Entirely

Existence-DependentPart

Part

Composition

Aggregation

Page 23: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S23 OO Concepts -2

Mr. Clinton’s hand is part-of Mr. Clinton & Mr.

Clinton is part-of U.S.A.

Therefore:

Mr. Clinton’s hand is part-of U.S.A. 23

Aggregation Problem

WARNING

Page 24: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S24 OO Concepts -2

24

Keypad

Number Keys Total Key Subtotal Key

Display Drawer

display display displaydrawer

*

Cash Register Example

Page 25: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S25 OO Concepts -2

25

Aggregation vs. Inheritance

Aggregation Inheritance

Instances of distinct classes Instances of a single class

“a-part-of” (APO) “a-kind-of” or “is-a” (AKO)

Contains superclass-of

Aggregate + parts Superclass + subclass

“and” relationship “or” relationship

Propagated only if specified Inheritance

Page 26: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S26 OO Concepts -2

• What is an association? Give examples

• Associations are usually bidirectional. Please describe.

• Describe the basic difference between aggregation and inheritance. What do they have in common?

• What do you think “multiple inheritance” means?

• Which type of association is more likely to yield savings in the amount of code required for implementation? why?

• Define the process of identifying objects, classes, inheritance, associations & aggregation, attributes, and behaviors

• Define Polymorphism with examples

• What do we mean by saying “Model/View/Controller”? 26

Discussion Questions

Page 27: Software Design Methodologies:  UML in Action

May-June 2001 ISISTAN Research Institute – Tandil, Argentina -- M.E. Fayad

L11-S27 OO Concepts -2

Define:

– Use Case

– Structured English

What are the good, bad, and ugly of Use Case?

27

Questions for the Next Lecture