UML_Lecture

Содержание

Слайд 2

About myself

Yi Luo
TA for EEL5881
3rd Year Phd student in CpE
Email: [email protected]
Office hour:

About myself Yi Luo TA for EEL5881 3rd Year Phd student in

Wednesday 3:00PM-5:00PM in HEC-365

Слайд 3

Acknowledgements

Slides material are taken from different sources including:
the slides of Mr. Shiyuan

Acknowledgements Slides material are taken from different sources including: the slides of
Jin’s UML class, EEL 4884, Fall 2003.
Object-Oriented and Classical Software Engineering, Sixth Edition, WCB/McGraw-Hill, 2005 Stephen R. Schach
UML resource page http://www.uml.org/

Слайд 4

Outline

What is UML and why we use UML?
How to use UML diagrams

Outline What is UML and why we use UML? How to use
to design software system?
What UML Modeling tools we use today?

Слайд 5

What is UML and Why we use UML?

UML → “Unified Modeling Language”
Language:

What is UML and Why we use UML? UML → “Unified Modeling
express idea, not a methodology
Modeling: Describing a software system at a high level of abstraction
Unified: UML has become a world standard
Object Management Group (OMG): www.omg.org

Слайд 6

What is UML and Why we use UML?

More description about UML:
It is

What is UML and Why we use UML? More description about UML:
a industry-standard graphical language for specifying, visualizing, constructing, and documenting the artifacts of software systems
The UML uses mostly graphical notations to express the OO analysis and design of software projects. 
Simplifies the complex process of software design

Слайд 7

What is UML and Why we use UML?

Why we use UML?
Use graphical

What is UML and Why we use UML? Why we use UML?
notation: more clearly than natural language (imprecise) and code (too detailed).
Help acquire an overall view of a system.
UML is not dependent on any one language or technology.
UML moves us from fragmentation to standardization.

Слайд 8

What is UML and Why we use UML?

What is UML and Why we use UML?

Слайд 9

How to use UML diagrams to design software system?

Types of UML Diagrams:
Use

How to use UML diagrams to design software system? Types of UML
Case Diagram
Class Diagram
Sequence Diagram
Collaboration Diagram
State Diagram
This is only a subset of diagrams … but are most widely used

Слайд 10

Use-Case Diagrams

A use-case diagram is a set of use cases
A use case

Use-Case Diagrams A use-case diagram is a set of use cases A
is a model of the interaction between
External users of a software product (actors) and
The software product itself
More precisely, an actor is a user playing a specific role
describing a set of user scenarios
capturing user requirements
contract between end user and software developers

Слайд 11

Use-Case Diagrams

Library System

Borrow

Order Title

Fine Remittance

Client

Employee

Supervisor

Boundary

Actor

Use Case

Use-Case Diagrams Library System Borrow Order Title Fine Remittance Client Employee Supervisor Boundary Actor Use Case

Слайд 12


Use-Case Diagrams

Actors: A role that a user plays with respect to

Use-Case Diagrams Actors: A role that a user plays with respect to
the system, including human users and other systems. e.g., inanimate physical objects (e.g. robot); an external system that needs some information from the current system.
Use case: A set of scenarios that describing an interaction between a user and a system, including alternatives.
System boundary: rectangle diagram representing the boundary between the actors and the system.

Слайд 13

Use-Case Diagrams

Association:
communication between an actor and a use case; Represented

Use-Case Diagrams Association: communication between an actor and a use case; Represented
by a solid line.
Generalization: relationship between one general use case and a special use case (used for defining special alternatives) Represented by a line with a triangular arrow head toward the parent use case.

Слайд 14

Use-Case Diagrams
Extend: a dotted line labeled <> with an arrow toward the

Use-Case Diagrams Extend: a dotted line labeled > with an arrow toward
base case. The extending use case may add behavior to the base use case. The base class declares “extension points”.
<>
Include: a dotted line labeled <> beginning at base use case and ending with an arrows pointing to the include use case. The include relationship occurs when a chunk of behavior is similar across more than one use case. Use “include” in stead of copying the description of that behavior.
<>

Слайд 15

Use-Case Diagrams

Figure 16.12

The McGraw-Hill Companies, 2005

Use-Case Diagrams Figure 16.12 The McGraw-Hill Companies, 2005

Слайд 16

Use-Case Diagrams

Both Make Appointment and Request Medication include Check Patient Record as

Use-Case Diagrams Both Make Appointment and Request Medication include Check Patient Record
a subtask (include)
The extension point is written inside the base case Pay bill; the extending class Defer payment adds the behavior of this extension point. (extend)
Pay Bill is a parent use case and Bill Insurance is the child use case. (generalization)

(TogetherSoft, Inc)

Слайд 17

Class diagram

A class diagram depicts classes and their interrelationships
Used for describing structure

Class diagram A class diagram depicts classes and their interrelationships Used for
and behavior in the use cases
Provide a conceptual model of the system in terms of entities and their relationships
Used for requirement capture, end-user interaction
Detailed class diagrams are used for developers

Слайд 18

Class diagram

Each class is represented by a rectangle subdivided into three compartments
Name
Attributes
Operations
Modifiers

Class diagram Each class is represented by a rectangle subdivided into three
are used to indicate visibility of attributes and operations.
‘+’ is used to denote Public visibility (everyone)
‘#’ is used to denote Protected visibility (friends and derived)
‘-’ is used to denote Private visibility (no one)
By default, attributes are hidden and operations are visible.

Слайд 19

Class diagram

Class diagram

Слайд 20

OO Relationships

There are two kinds of Relationships
Generalization (parent-child relationship)
Association (student enrolls in

OO Relationships There are two kinds of Relationships Generalization (parent-child relationship) Association
course)
Associations can be further classified as
Aggregation
Composition

Слайд 21

Subtype2

Supertype

Subtype1

OO Relationships: Generalization

-Inheritance is a required feature of object orientation
-Generalization expresses

Subtype2 Supertype Subtype1 OO Relationships: Generalization -Inheritance is a required feature of
a parent/child relationship among related classes.
Used for abstracting details in several layers

Regular
Customer

Loyalty
Customer

Customer

Example:


Слайд 22

Represent relationship between instances of classes
Student enrolls in a course
Courses have students
Courses

Represent relationship between instances of classes Student enrolls in a course Courses
have exams
Etc.
Association has two ends
Role names (e.g. enrolls)
Multiplicity (e.g. One course can have many students)
Navigability (unidirectional, bidirectional)

OO Relationships: Association

Слайд 23

Association: Multiplicity and Roles

University

Person

1

0..1

*

*

Multiplicity
Symbol Meaning
1 One and only one
0..1 Zero or one
M..N From M to N

Association: Multiplicity and Roles University Person 1 0..1 * * Multiplicity Symbol
(natural language)
* From zero to any positive integer
0..* From zero to any positive integer
1..* From one to any positive integer

teacher

employer

Role

Role
“A given university groups many people; some act as students, others as teachers. A given student belongs to a single university; a given teacher may or may not be working for the university at a particular time.”

student

Слайд 24

Class diagram

[from UML Distilled Third Edition]

Class diagram [from UML Distilled Third Edition]

Слайд 25

Association: Model to Implementation

Class Student {
Course enrolls[4];
}
Class Course {
Student have[];
}

Student

Course

enrolls

has

*

4

Association: Model to Implementation Class Student { Course enrolls[4]; } Class Course

Слайд 26

OO Relationships: Composition

Class W

Class P1

Class P2

Association
Models the part–whole relationship
Composition
Also models

OO Relationships: Composition Class W Class P1 Class P2 Association Models the
the part–whole relationship but, in addition, Every part may belong to only one whole, and If the whole is deleted, so are the parts
Example:
A number of different chess boards: Each square belongs to only one board. If a chess board is thrown away, all 64 squares on that board go as well.

Whole Class

Part Classes

Example

Figure 16.7

The McGraw-Hill Companies, 2005

[From Dr.David A. Workman]

Слайд 27

OO Relationships: Aggregation

Class C

Class E1

Class E2

AGGREGATION

Container Class

Containee Classes

Bag

Apples

Milk

Example

Aggregation:
expresses a

OO Relationships: Aggregation Class C Class E1 Class E2 AGGREGATION Container Class
relationship among instances of related classes. It is a specific kind of Container-Containee relationship.
express a more informal relationship than composition expresses.
Aggregation is appropriate when Container and Containees have no special access privileges to each other.

[From Dr.David A. Workman]

Слайд 28

Aggregation vs. Composition
Composition is really a strong form of association
components have only

Aggregation vs. Composition Composition is really a strong form of association components
one owner
components cannot exist independent of their owner
components live or die with their owner
e.g. Each car has an engine that can not be shared with other cars.
Aggregations
may form "part of" the association, but may not be essential to it. They may also exist independent of the aggregate. e.g. Apples may exist independent of the bag.

Слайд 29

Good Practice: CRC Card

Class Responsibility Collaborator
easy to describe how classes work by

Good Practice: CRC Card Class Responsibility Collaborator easy to describe how classes
moving cards around; allows to quickly consider alternatives.


Слайд 30

Interaction Diagrams

show how objects interact with one another
UML supports two types of

Interaction Diagrams show how objects interact with one another UML supports two
interaction diagrams
Sequence diagrams
Collaboration diagrams

Слайд 31

Sequence Diagram(make a phone call)

Caller

Phone

Recipient

Picks up

Dial tone

Dial

Ring notification

Ring

Picks up

Hello

Sequence Diagram(make a phone call) Caller Phone Recipient Picks up Dial tone

Слайд 32

Sequence Diagram:Object interaction

Self-Call: A message that an
Object sends to itself.
Condition: indicates

Sequence Diagram:Object interaction Self-Call: A message that an Object sends to itself.
when a message is sent. The message is sent only if the condition is true.
Iteration
Condition

Слайд 33

Sequence Diagrams – Object Life Spans

Creation
Create message
Object life starts at that point
Activation
Symbolized

Sequence Diagrams – Object Life Spans Creation Create message Object life starts
by rectangular stripes
Place on the lifeline where object is activated.
Rectangle also denotes when object is deactivated.
Deletion
Placing an ‘X’ on lifeline
Object’s life ends at that point
Activation bar

Слайд 34

Sequence Diagram

Sequence diagrams demonstrate the behavior of objects in a use case

Sequence Diagram Sequence diagrams demonstrate the behavior of objects in a use
by describing the objects and the messages they pass.
The horizontal dimension shows the objects participating in the interaction.
The vertical arrangement of messages indicates their order.
The labels may contain the seq. # to indicate concurrency.

Message

Слайд 35

Interaction Diagrams: Collaboration diagrams

User

Catalog

Reservations

start

1: look up

2: title data

3 : [not available]

Interaction Diagrams: Collaboration diagrams User Catalog Reservations start 1: look up 2:
reserve title

4 : title returned

5 : hold title

6 : borrow title

6: remove reservation

5: title available

Collaboration diagrams are equivalent to sequence diagrams. All the features of sequence diagrams are equally applicable to collaboration diagrams
Use a sequence diagram when the transfer of information is the focus of attention
Use a collaboration diagram when concentrating on the classes

Слайд 36

State Diagrams (Billing Example)

State Diagrams show the sequences of states an

State Diagrams (Billing Example) State Diagrams show the sequences of states an
object goes through during its life cycle in response to stimuli, together with its responses and actions; an abstraction of all possible behaviors.

Unpaid

Start

End

Paid

Invoice created

paying

Invoice destroying

Слайд 37

State Diagrams (Traffic light example)

Yellow

Red

Green

Traffic Light

State

Transition

Green timer expires

Yellow timer expires

Car trips sensor

State Diagrams (Traffic light example) Yellow Red Green Traffic Light State Transition

Event

Start

Слайд 38

What UML Modeling tools we use today?

List of UML tools http://en.wikipedia.org/wiki/List_of_UML_tools
ArgoUML: http://argouml.tigris.org/
Rational

What UML Modeling tools we use today? List of UML tools http://en.wikipedia.org/wiki/List_of_UML_tools
Rose (www.rational.com) by IBM
UML Studio 7.1 ( http://www.pragsoft.com/) by Pragsoft Corporation: Capable of handling very large models (tens of thousands of classes). Educational License US$ 125.00; Freeware version.
TogetherSoft Control Center; TogetherSoft Solo (http://www.borland.com/together/index.html) by Borland

Слайд 39

Conclusion

UML is a standardized specification language for object modeling
Several UML diagrams:
use-case diagram:

Conclusion UML is a standardized specification language for object modeling Several UML
a number of use cases (use case models the interaction between actors and software)
Class diagram: a model of classes showing the static relationships among them including association and generalization.
Sequence diagram: shows the way objects interact with one another as messages are passed between them. Dynamic model
State diagram: shows states, events that cause transitions between states. Another dynamic model reflecting the behavior of objects and how they react to specific event
There are several UML tools available
Имя файла: UML_Lecture.pptx
Количество просмотров: 35
Количество скачиваний: 0