0% found this document useful (0 votes)
27 views53 pages

Chapter 3

The document discusses the history and development of the Unified Modeling Language (UML). It describes UML's origins from the merging of several object-oriented modeling languages in the 1990s. It then explains the basic building blocks of UML including things, relationships, and diagrams.

Uploaded by

metekia sada
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views53 pages

Chapter 3

The document discusses the history and development of the Unified Modeling Language (UML). It describes UML's origins from the merging of several object-oriented modeling languages in the 1990s. It then explains the basic building blocks of UML including things, relationships, and diagrams.

Uploaded by

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

Chapter 2: UML

 Background
 What is UML for?
 Building blocks of UML

1
UML History
 OO languages appear mid 70’s to late 80’s (cf. Budd: communication and complexity)

 Between ’89 and ’94, OO methods increased from 10 to 50.

 Unification of ideas began in mid 90’s.


 Rumbaugh joins Booch at Rational ’94
 v0.8 draft Unified Method ’95 pre-UML
 Jacobson joins Rational ’95
 UML v0.9 in June ’96

 UML 1.0 offered to OMG in January ’97


 UML 1.1 offered to OMG in July ’97
 Maintenance through OMG RTF UML 1.x
 UML 1.2 in June ’98
 UML 1.3 in fall ’99
 UML 1.5 http://www.omg.org/technology/documents/formal/uml.htm

 UML 2.0 underway http://www.uml.org/


UML 2.0
 IBM-Rational now has Three Amigos
 Grady Booch - Fusion
 James Rumbaugh – Object Modeling Technique (OMT)
 Ivar Jacobson – Object-oriented Software Engineering: A Use Case Approach (Objectory)
 ( And David Harel - StateChart)

 Rational Rose http://www-306.ibm.com/software/rational/

2
Unified Modeling Language (UML)
 An effort by IBM (Rational) – OMG to standardize OOA&D notation

 Combine the best of the best from


 Data Modeling (Entity Relationship Diagrams);
Business Modeling (work flow); Object Modeling

 Component Modeling (development and reuse - middleware, COTS/GOTS/OSS/…:)

 Offers vocabulary and rules for communication


 Not a process but a language

de facto industry standard


3
UML is for Visual Modeling
A picture is worth a thousand words!

- standard graphical notations: Semi-formal


- for modeling enterprise info. systems, distributed Web-based applications, real time embedded systems,

Sales Places Order


Representative Customer

Fulfill Order

Item
Business Process
via
Ships the Item

- Specifying & Documenting: models that are precise, unambiguous, complete


 UML symbols are based on well-defined syntax and semantics.
 analysis, architecture/design, implementation, testing decisions.
- Construction: mapping between a UML model and OOPL.
4
Three (3) basic building blocks of UML (cf. Harry)
Water

have Fresh water

Rivers
Oceans
have

have Salt water


live in
have
Fish have
Crocodiles
Penguins

 Things - important modeling concepts


Just glance thru
for now
 Relationships - tying individual things

 Diagrams - grouping interrelated collections of things


and relationships 5
3 basic building blocks of UML - Things

 UML 1.x
 Structural — nouns/static of UML models (irrespective of time).

Main
 Behavioral — verbs/dynamic parts of UML models.

 Grouping — organizational parts of UML models.


 Annotational — explanatory parts of UML models.

6
Structural Things in UML- 7 Kinds (Classifiers)
 Nouns.
 Conceptual or physical elements.

Active Class Component Interface Node


(replaceable part, (collection of externally
Class (processes/threads)
Visible ops)
(computational
realizes interfaces) resource at run-time,
Student Event Mgr processing power
std_id thread w. memory)
grade time Course.cpp
changeLevel( ) Start IGrade
setGrade( ) suspend( ) <<interface>> UnivWebServer
getGrade( ) stop( ) IGrade

setGrade()
getGrade()

Register Manage Course


for Courses Registration

Use Case Collaboration


(a system service (chain of responsibility
-sequence of shared by a web of interacting objects,
Interactions w. actor) structural and behavioral) 7
Behavioral Things in UML
 Verbs.
 Dynamic parts of UML models: “behavior over time”
 Usually connected to structural things.

Two primary kinds of behavioral things:


 Interaction
a set of objects exchanging messages, to accomplish a specific purpose.

harry: Student katie: Professor


ask-for-an-A
name = “Harry Kid” name = “Katie Holmes”

 State Machine
specifies the sequence of states an object or an interaction goes through during its
lifetime in response to events.
received-an-A/
inStudy buy-beer inParty
8
sober/turn-on-PC
Grouping Things in UML: Packages
- For organizing elements (structural/behavioral) into groups.
- Purely conceptual; only exists at development time.
- Can be nested.
- Variations of packages are: Frameworks, models, & subsystems.

University Administration

Course Manager Course Manager


Student Admission

-Student
+Department

Annotational Things in UML: Note


- Explanatory/Comment parts of UML models - usually called adornments
- Expressed in informal or formal text.
operation()
flexible {for all g in children
g.operation()
drop-out dates }
9
3 basic building blocks of UML - Relationships
Student University
attends
1. Associations
Structural relationship that describes a set of links, a link being a connection between
objects. variants: aggregation & composition

Student Person
2. Generalization
a specialized element (the child) is more specific the generalized element.

Student
3. Realization IGrade
one element guarantees to carry out what is expected by the other element.
(e.g, interfaces and classes/components; use cases and collaborations)

harry: Student Student


<<instanceOf>>
4. Dependency
a change to one thing (independent) may affect the semantics of the other thing (dependent).
(direction, label are optional) 10
3 basic building blocks of UML - Diagrams
A connected graph: Vertices are things; Arcs are relationships/behaviors.

UML 1.x: 9 diagram types. UML 2.0: 12 diagram types


Structural Diagrams Structural Diagrams
Represent the static aspects of a system.
 Class;
 Class;
Object Object
 Component
 Component
 Deployment
 Deployment
 Composite Structure
 Package

Behavioral Diagrams Behavioral Diagrams Interaction Diagrams


Represent the dynamic aspects.
 Use case  Use case
 Sequence;  Sequence;
Collaboration Communication
 Statechart  Statechart
 Activity  Activity
 Interaction11
Overvie
 Timing
Diagrams in UML
The UTD wants to computerize its registration system

 The Registrar sets up the curriculum for a semester

 Students select 3 core courses and 2 electives

 Once a student registers for a semester, the billing system is


notified so the student may be billed for the semester

 Students may use the system to add/drop courses


for a period of time after registration

 Professors use the system to set their preferred course offerings


and receive their course offering rosters after students register

 Users of the registration system are assigned passwords


which are used at logon validation

What’s most important? 12


Diagrams in UML – Actors in Use Case Diagram
 An actor is someone or some thing that must interact with the
system under development

The UTD wants to computerize its registration system

 The Registrar sets up the curriculum for a semester


Registrar

 Students select 3 core courses and 2 electives


Student

 Once a student registers for a semester, the billing system is


notified so the student may be billed for the semester Billing System

 Students may use the system to add/drop courses


for a period of time after registration

 Professors use the system to set their preferred course offerings


and receive their course offering rosters after students register
Professor
 Users of the registration system are assigned passwords 13
which are used at logon validation
Diagrams in UML – Use Cases in Use Case Diagram
 A use case is a sequence of interactions between an actor and the system
Maintain
The UTD wants to computerize its registration system Curriculum

 The Registrar sets up the curriculum for a semester


Register
for Courses
Registrar
 Students select 3 core courses and 2 electives
Student

 Once a student registers for a semester, the billing system is


notified so the student may be billed for the semester
Billing System

 Students may use the system to add/drop courses


for a period of time after registration Request
Course Roster
 Professors use the system to set their preferred course offerings
and receive their course offering rosters after students register
Set
Professor Course Offerings
 Users of the registration system are assigned passwords
which are used at logon validation
14
Diagrams in UML – Use Case Diagram
 Use case diagrams depict the relationships between actors and use cases

UTD Registration System system boundary

Maintain
Curriculum
Registrar

Register
for Courses
Billing System
Student
Manage
Seminar

Request
Course Roster

Professor Set Anything wrong?


Course Offerings
15
Diagrams in UML - Uses and Extends in Use Case Diagram

A uses relationship shows behavior common to one or more use cases

An extends relationship shows optional/exceptional behavior

<<uses>>
<<extends>>
Register for courses

Register for <<uses>>


Distance Learning courses Logon validation

<<uses>>

Maintain curriculum

Create course
<<uses>>

16
Maintain Schedule
Diagrams in UML – Flow of Events for each use case:
Typical contents:
How the use case starts and ends
Normal flow of events (focus on the normal first!)
Alternate/Exceptional flow of events

Flow of Events for Creating a Course Registrar Create Course

 This use case begins after the Registrar logs onto the Registration System
with a valid password.

 The registrar fills in the course form with the appropriate semester and
course related info.

 The Registrar requests the system to process the course form.


 The system creates a new course, and this use case ends
17
Diagrams in UML – Interaction Diagrams
A use case diagram presents an outside view of the system.

Then, how about the inside view of the system?

 Interaction diagrams describe how use cases are realized


in terms of interacting objects.

 Two types of interaction diagrams


 Sequence diagrams
 Collaboration (Communication) diagrams

18
Diagrams in UML - Sequence Diagram
 A sequence diagram displays object interactions arranged in a time
sequence

course form : theManager :


: Registrar CourseForm CurriculumManager
Registrar Create Course
This use case begins
after the Registrar 1: set course info
logs onto the
Registration
System with a valid 2: request processing
password.
The registrar fills in the 3: add course
course form with
the appropriate
semester and
4: <<create>> aCourse :
course related info. Course
The Registrar requests
the system to
process the course
form.
The system creates a
new course, and
this use case ends

Traceability! 19
Diagrams in UML – Collaboration (Communication)
 Displays object interactions organized around objects and their direct
links to one another.
 Emphasizes the structural organization of objects that send and receive
messages.
course form:
theManager : 1: set course info CourseForm
course form : 2: request processing
: Registrar CourseForm CurriculumManager

1: set course info

2: request processing
: Registrar 3: add course

3: add course

4: <<create>> aCourse:
Course
theManager :
aCourse: CurriculumManager
Course
4: <<create>>

Traceability!

20
Diagrams in UML – Collaboration (Communication)
 What would be the corresponding collaboration diagram?

: Student registration registration math 101 math 101


form manager section 1

1: fill in info

2: submit

3: add course(Sue, math 01)


4: are you open?
5: are you open?
6: add (Sue)
7: add (Sue)

Which use case could this be for? How about <---------- 21


Skip the following for now: In M3.2

22
Sequence Diagrams & Some Programming
:Selection :Purchase

purchase
buyMajor

buyMinor

create(cashTender)
:Payment

public Class Selection


{ private Purchase myPurchase = new Purchase();
private Payment myPayment;
public void purchase()
{ myPurchase.buyMajor();
myPurchase.buyMinor():
myPayment = new Payment( cashTender );
//. .
}
// . . 23
}
Interactions - Modeling Actions
 Simple asynchronous in 2.0 (stick arrowhead) – no return value expected at end of callee
activation
 Call activation of caller may end before callee’s
 Return
 Send half arrow in 1.x

c : Client 1
p : PlanningAgent

<<create>> : TicketAgent

actual parameter
setItenerary( i )
calculateRoute()
loop return
route return value
call on self

for each conference


<<destroy>>
X end of object life
notify() send

destroy: e.g., in C++ manual garbage collection; in Java/C#, unnecessary natural death/
self destruction

24
Sequence Diagrams – Generic vs. Instance
 2 forms of sd:
 Instance sd: describes a specific scenario in detail; no conditions, branches or loops.
 Generic sd: a use case description with alternative courses.

ob3:C3 ob3:C3 ob3:C3 ob3:C3

op1
ob1:C1
[x>0] foo(x)
conditional ob2:C2 concurrent lifelines
- for conditionals
[x<0] bar(x) do(z) - for concurrency
do(w)
[z=0] jar(z) [z=0] jar(z)

linking sequence diagrams

recurse()
Here, conditional or concurrency?
recursion
25
Interaction Diagram: sequence vs communication
objects
object
p : StockQuotePublisher s1 : StockQuoteSubscriber s2 : StockQuoteSubscriber role:ClassName
classifiers or their in
use cases or actors
attach(s1)
attach(s2) Procedure call, RMI, JDBC, …
Observer
design
Time notify() pattern
update()
{update < 1 minutes} Activations
getState()
- Show duration of execution
update() - Shows call stack
- Return message
getState() Implicit at end of activation
Explicit with a dashed arrow

3 : notify() 4 : update()
s1 : StockQuoteSubscriber
1 : attach(s1)
6 : getState()
p : StockQuotePublisher 5 : update()

2 : attach(s2) s2 : StockQuoteSubscriber
7 : getState() 26
Deployment Diagrams
 Deployment diagram shows physical
components of a new system
Node is a physical component
Artifact is an executable module
Artifacts are components after they have been
compiled into executables

27
Sample Deployment Diagram
of an Internet System

28
Skip end: resume

29
Diagrams in UML - Class Diagrams

A class diagram shows the existence of classes and their relationships
 Recall: A class is a collection of objects with common structure, common
behavior, common relationships and common semantics
 Some classes are shown through the objects in sequence/collaboration
diagram

theManager : CurriculumManager Course


CurriculumManager

4: <<create>> aCourse :
Course

Traceability!

registration registration RegistrationManager


form manager
3: add course(Sue, math 01)
addCourse(Student,Course)
30
Diagrams in UML - Class Diagrams: static structure in the system
 Naming & (often) 3 Sections;
 Inheritance (as before);
 Relationships - Multiplicity and Navigation
CurriculumManager

ScheduleAlgorithm 1
RegistrationForm

0..*
1 RegistrationManager 0..*
addStudent(student, course)
1 Course
name
0..* numberCredits
User
name Student
open()
addStudent(StudentInfo)
major

1
1..10
Professor 1..*
4 CourseOffering
tenureStatus location
1
0..4
Reading? open()
addStudent(StudentInfo)
31
Diagrams in UML – Object Diagrams
 Shows a set of objects and their relationships.
 As a static snapshot.
harry: Student ooad06S: Course
name = “OOAD”
name = “Harry Kid”

katie: Professor ooado: CourseOffering


name = “Katie Holmes” location = “Fujitsu”

Anything wrong?

arch06F: Course
tom: Student
name = “Sw Architecture”
harry1: Professor
name = “Tom Cruise”
name = “Harry William”

alg06F: Course
surie: Professor arch: CourseOffering name = “Adv Algorithms”
name = “Surie Holmes” location = “UTD”
32
Diagrams in UML – State Transition Diagram (Statechart Diagram)
• The life history (often of a given class: from class to object behavior)
• States, transitions, events that cause a transition from one state to another
• Actions that result from a state change

initial (internal)
condition
event/action Add student [count < 10]
Add Student /
state Set count = 0
Initialization
State name Open
do: Initialize course
entry: Register student
activity exit: Increment count

Cancel

Cancel [ count = 10 ]
Canceled
do: Notify registered students
Closed
Cancel do: Finalize course

final
What life history/class is this for? Anything wrong? 33
…until the drop date?
Diagrams in UML – Activity Diagrams
• A special kind of statechart diagram that shows the flow from activity to activity.
initial

Initialize course activity

Add student

fork/spawn

Notify Registrar Notify Billing


What is this for?
Traceability???
Synchronization
[else]
Can you model this using SD?
[ count < 10 ]
guard
Can you model this using CD?
Close course final 34
Diagrams in UML – Component Diagram
shows the organizations and dependencies among a set of
components (mostly <<uses>>).
In UML 1.1, a component represented implementation items, such as files and executables;

In UML 2.0, a component is a replaceable/reusable, architecture/design-time construct w.
interfaces
Register.exe
Billing.exe
Billing

User
Course
People.dll
Course.dll

Student Professor
Course Course
Offering

Student Professor

35
Diagrams in UML – Deployment Diagram
• shows the configuration of run-time processing elements and the
software processes living on them.
• visualizes the distribution of components across the enterprise.

Registrar Webserver Course Oracle Server


Register.exe Course
Course Offering
RMI, sockets TCP/IP

wireless
Library Server Main Building Solaris
People.dll Billing.exe

Dorm PC

People Database
Student
Professor
36
Identifying Object Behaviour—
The State Machine Diagram (SMD)
 SSDs give external view of object behaviour – messages passed
around but do not show, what an object does when it gets a message
 There is a need to specify internal logic for each object, i.e., a
description of the actions that the objects perform themselves
 State machine diagram is UML a 2.0 diagram that models object
internal behaviour, states and transitions
Complex problem domain classes can be modeled

 Each object is an instance of a class, and comes into existence in


some manner
 During its existence it is “in” certain states and makes transitions
from state to state
 These states and the changes an object makes from state to state are
shown in SMD (two main symbols: state and transitions)

37
Identifying Object Behaviour—
The State Machine Diagram
 State of an object
 A condition that occurs during its life when it satisfies some criterion,
performs some action, or waits for an event
 Each state has unique name (e.g., “on”, “working”, “loading equipment”,
etc.) and is a semipermanent condition or status (because external
events can interrupt them)
 Action is an activity performed by an object in a particular state
 A state is represented by a rectangle with rounded corners (with the name of
the state inside)
 Any actions that must be performed during the period of the state are placed
below the state name in the rectangle
 Transition - movement of an object from one state to another state
 Considered to be short in duration and cannot be interrupted
 Once started, a transition runs to completion by taking the object to the
new state (called destination state)
38
Simple SMD for a Printer

39
State Machine Terminology

 Pseudostate – the starting point of a state machine, indicated


by a black dot
 Origin state – the original state of an object from which the
transition occurs
 Destination state – the state to which an object moves after
the completion of a transition
 Message event – the trigger for a transition, which causes the
object to leave the origin state
 Guard condition – a true/false test to see whether a transition
can fire
 Action expression – a description of the activities performed
as part of a transition
40
Composite States and Concurrency—
States within a State

41
Concurrent Paths for Printer in the On
State

42
Relationships among OO models
43
State Machine Diagram and SSD

•Each column is labelled with the name of a class (the columns identify all
of the classes in the system); each row is for one sequence diagram; the Xs
in the cells show which classes are involved in which sequence diagram).
• An SMD for a class is based on the entire column for that class
• Every cell with X provides information about the messages to and from the
class

44
Rules for Developing State Machine
Diagram
 Review domain class diagram, select important ones, and
list all state and exit conditions
 Begin building state machine diagram fragments for each
class
 Sequence fragments in correct order and review for
independent and concurrent paths
 Expand each transition with message event, guard-
condition, and action-expression
 Review and test each state machine diagram

45
States and Exit Transitions for OrderItem

46
Partial State Machine for OrderItem

47
Final State Machine for OrderItem

48
Order Domain Class for RMO—
States and Exit Transitions

49
First-Cut State Machine Diagram for
Order

50
Second-Cut State Machine Diagram for
Order

51
3 basic building blocks of UML - Diagrams
Here, UML 1.x first Using UML Concepts in a Nutshell
(UML 2.0 later)
 Display the boundary of a system & its
Use case major functions using use cases and actors

Sequence;  Illustrate use case realizations with


Collaboration interaction diagrams
(Communication)

Class;  Represent a static structure of a system


Object using class diagrams

Statechart  Model the behavior of objects with state


Activity transition diagrams

Component  Reveal the physical implementation


Deployment architecture with component & deployment
diagrams
 Extend your functionality with stereotypes
52
Summary

 Background

 What is UML for (both 1.x and 2.0)?


for visualizing, specifying, constructing, and documenting models

 Building blocks of UML


Things, Relationships (4 kinds) and Diagrams (9 different kinds)

53

You might also like