You are on page 1of 7

UML Example

http://www.geocities.com/siliconvalley/network/1582/ml!example.htm"toc
#a$le o% &ontents
1 Elevator Problem
2 Unified Modeling Language
3 Analysis
3.1 Use Case Dagram
3.2 Class Diagram
3.3 State Diagram
Design
.1 Se!uen"e Diagram
.2 Collaboration Diagram
# Detail Design
#.1 Detail Class Diagram
#.2 Detail $%reation Des"ri%tion
#.3 Pseud&Code
'. A"(no)ledgement
'. (ntro)ction
*+e aim of t+is tutorial is to s+o) +o) to use UML in ,real, soft)are develo%ment
environment.
1. Elevator *ro$lem
A %rodu"t is to be installed to "ontrol elevators in a building )it+ m floors. *+e %roblem
"on"erns t+e logi" re!uired to move elevators bet)een floors a""ording to t+e follo)ing
"onstraints-

Ea"+ elevator +as a set of m buttons. one for ea"+ floor. *+ese illuminate )+en
%ressed and "ause t+e elevator to visit t+e "orres%onding floor. *+e illumination is
"an"eled )+en t+e elevator visits t+e "orres%onding floor.

Ea"+ floor. e/"e%t t+e first floor and to% floor +as t)o buttons. one to re!uest and
u%&elevator and one to re!uest a do)n&elevator. *+ese buttons illuminate )+en
%ressed. *+e illumination is "an"eled )+en an elevator visits t+e floor and t+en
moves in t+e desired dire"tion.

0+en an elevator +as no re!uests. it remains at its "urrent floor )it+ its doors
"losed.

2. Uni%ie) Mo)eling Langage
UML is a modeling language t+at only s%e"ifies semanti"s and notation but no %ro"ess is
"urrently defined. *+us. )e de"ided to do t+e analysis as follo)s1

Use Case Diagram
Class Diagram
Se!uen"e Diagram
Collabration Diagram
State Diagram
+. ,nalysis
+.1. Use case )iagram
Use "ase des"ri%tion-

A generali2ed des"ri%tion of +o) a system )ill be used.
Provides an overvie) of t+e intended fun"tionality of t+e system.
Understandable by laymen as )ell as %rofessionals.
Use Case Diagram-




Elevator basi" s"enario t+at "an be e/tra"ted from Use Case Diagram-

Passenger %ressed floor button
Elevator system dete"ts floor button %ressed
Elevator moves to t+e floor
Elevator doors o%en
Passenger gets in and %resses elevator button
Elevator doors "loses
Elevator moves to re!uired floor
Elevator doors o%en
Passenger gets out
Elevator doors "loses

+.2. &lass -iagram
Class diagrams s+o) t+e stati" stru"ture of t+e ob3e"t. t+eir internal stru"ture. and t+eir
relations+i%s.
&lass )iagram:





+.+. .tate )iagram
A state diagram s+o)s t+e se!uen"es of states an ob3e"t goes t+roug+ during it4s life "y"le
in res%onse to stimuli. toget+er )it+ its res%onses and a"tions.


/. -esign
*+e design %+ase s+ould %rodu"e t+e detailed "lass diagrams. "ollaboration diagrams.
se!uen"e diagrams. state diagrams. and a"tivity diagram. 5o)ever. t+e elevator %roblem
is too sim%le for an a"tivity diagram. *+us. )e are not using an a"tivity diagram for t+e
elevator %roblem.
/.1. .e0ence -iagram
A se!uen"e diagram and "ollaboration diagram "onveys similar information but
e/%ressed in different )ays. A Se!uen"e diagram s+o)s t+e e/%li"it se!uen"e of
messages suitable for modeling a real&time system. )+ereas a "ollobration diagram s+o)s
t+e relations+i%s bet)een ob3e"ts.
.e0ence -iagrams:



.e0ence -iagram %or .erving Elevator 1tton


.e0ence -iagram %or .erving -oor 1tton



/.2. &olla$oration )iagram

Des"ribes t+e set of intera"tions bet)een "lasses or ty%es
S+o)s t+e relations+i%s among ob3e"ts
&olla$ration )iagrams:


&olla$ration -igaram %or .erving Elevator 1tton

&olla$ration -igaram %or .erving -oor 1tton


5. -etail -esign

5.1. -etail &lass -iagram


5.2. -etail 2peration -escription

Module 6ame Elevator7Control--Elevator7"ontrol7loo%
Module *y%e Met+od
8n%ut Argument 6one
$ut%ut Argument 6one
Error Message 6one
9ile A""ess 6one
9ile C+ange 6one
Met+od 8nvo(e button--illuminate. button--"an"el7illumination.
door--o%en. door--"lose. elevator--move.
elevator--sto%
6arative

5.+. *se)o!&o)e

void elevator7"ontrol :void;
<
)+ile a button +as been %ressed
if button not on
<
button--illuminate1
u%date re!uest list1
=
else if elevator is moving u%
<
if t+ere is no re!uest to sto% at floor f
Elevator--move one floor u%1
else

=
3. ,cknowle)gement
*+is e/am%le )as develo%ed for to%i" in soft)are engineering in >anderbilt
University by myself and my best friends-
o 5elen ?ioa
o >aleria Amburge
o Parvat+i @a3aAo%al

You might also like