Uml With Examples
Uml With Examples
Page 1 of 7
UML By Examples
Table of Contents
1 Elevator Problem
2 Unified Modeling Language
3 Analysis
3.1 Use Case Dagram
3.2 Class Diagram
3.3 State Diagram
4 Design
4.1 Sequence Diagram
4.2 Collaboration Diagram
5 Detail Design
5.1 Detail Class Diagram
5.2 Detail Opreation Description
5.3 Pseud-Code
6. Acknowledgement
Home
UML
Resources
0. Introduction
The aim of this tutorial is to show how to use UML in "real" software development environment.
1. Elevator Problem
A product is to be installed to control elevators in a building with m floors. The problem concerns
the logic required to move elevators between floors according to the following constraints:
{
Each elevator has a set of m buttons, one for each floor. These illuminate when pressed and
cause the elevator to visit the corresponding floor. The illumination is canceled when the
elevator visits the corresponding floor.
Each floor, except the first floor and top floor has two buttons, one to request and upelevator and one to request a down-elevator. These buttons illuminate when pressed. The
illumination is canceled when an elevator visits the floor and then moves in the desired
direction.
When an elevator has no requests, it remains at its current floor with its doors closed.
3. Analysis
http://www.geocities.com/SiliconValley/Network/1582/uml-example.htm?200719
9/19/2007
Page 2 of 7
Elevator basic scenario that can be extracted from Use Case Diagram:
{
{
{
{
{
{
{
{
{
{
http://www.geocities.com/SiliconValley/Network/1582/uml-example.htm?200719
9/19/2007
Page 3 of 7
4. Design
The design phase should produce the detailed class diagrams, collaboration diagrams, sequence
diagrams, state diagrams, and activity diagram. However, the elevator problem is too simple for an
activity diagram. Thus, we are not using an activity diagram for the elevator problem.
http://www.geocities.com/SiliconValley/Network/1582/uml-example.htm?200719
9/19/2007
Page 4 of 7
http://www.geocities.com/SiliconValley/Network/1582/uml-example.htm?200719
9/19/2007
Page 5 of 7
Collabration diagrams:
5. Detail Design
5.1. Detail Class Diagram
http://www.geocities.com/SiliconValley/Network/1582/uml-example.htm?200719
9/19/2007
Page 6 of 7
Elevator_Control::Elevator_control_loop
Method
None
None
None
None
None
button::illuminate, button::cancel_illumination,
door::open, door::close, elevator::move, elevator::stop
5.3. Pseudo-Code
void elevator_control (void)
{
while a button has been pressed
if button not on
{
button::illuminate;
update request list;
}
else if elevator is moving up
{
if there is no request to stop at floor f
Elevator::move one floor up;
else
}
http://www.geocities.com/SiliconValley/Network/1582/uml-example.htm?200719
9/19/2007
Page 7 of 7
6. Acknowledgement
This example was developed for topic in software engineering in Vanderbilt University by
myself and my best friends:
Helen Xioa
Valeria Amburge
Parvathi RajaGopal
http://www.geocities.com/SiliconValley/Network/1582/uml-example.htm?200719
9/19/2007