You are on page 1of 13

Introduction to UML

Diagrams
Itntroduction to UML by Jan Pettersen Nytun, page 1

Building blocks of the UML


As part of a model you have:
1 modeling elements 2 relationships between the modeling elements 3 diagrams that group and visualize the modeling elements and the relations between them. E.g. class diagram: Company 1 1..* Department 1..* Office

LocatedAt * *

Itntroduction to UML by Jan Pettersen Nytun, page 2

3 Diagrams
A diagram is typically a view of a part of the model, showing modeling elements and some of the relationships between them. A diagram do not have to be complete, some elements may be missing or presented in a simplified fashion. UML: A well-formed model is one that is semantically self-consistent and in harmony with all related models.
Itntroduction to UML by Jan Pettersen Nytun, page 3

There are 9 types of diagrams in UML


Dynamic views
Sequence Diagrams Collaboration Diagrams Activity Diagrams Statechart Diagrams
Some part of the model might not be visible on any diagram

Static views
Use Case Diagrams Class Diagrams Object Diagrams

Model

Component Diagrams Deployment Diagrams

Itntroduction to UML by Jan Pettersen Nytun, page 4

3.1 Use case diagram


actor register a person edit a registration/ delete a registration User include navigate/view the register include relationship view next person view previous person

include

association

include

use case

system boundary
Itntroduction to UML by Jan Pettersen Nytun, page 5

Use Case Diagram - One More Example


A use case is a specific way of using the system by performing some part of the functionality. Each use case constitutes a complete course of events initiated by an actor, and it specifies the interaction that takes place between an actor and the system.... I. Jacobson

Person

Register as student

<<become>>

Stude nt
<<becom e>>

Reg is te r for co urse

Adm

Register for exam

CourseParti cipan t

Working with cours e

Instructor

Make/edit course

Lecture r

Itntroduction to UML by Jan Pettersen Nytun, page 6

3.2 Class Diagram


Person
name : String email : String homePage : String
1 responsible for

Course
*

CourseModule
1..* name

1 tech. responsible for

: String * name description : String


1

: String description : String


1

Student

* * StudentCourseProfile * finished : boolean

When a student register for course a StudentCourseProfile object will be made!


Itntroduction to UML by Jan Pettersen Nytun, page 7

A Class Diagram With Navigation


Person
1 responsible for

Course
*
1..*

name : String 1 tech. responsible for imail : String homePage : String

CourseModule
name : String description : String
1

: String * name description : String


1 *

Student

* StudentCourseProfile * finished : boolean

Itntroduction to UML by Jan Pettersen Nytun, page 8

A Class Diagram - Mapping to Java


Person
1 responsible for

Course

name : String 1 tech. responsible for imail : String homePage : String

: String * name description : String


1

Student

* StudentCourseProfile finished : boolean public class Student extends Person {{ public class Student extends Person //// ////Navigation Navigation public StudentCourseProfile[] public StudentCourseProfile[] studentCourseProfile; studentCourseProfile; public Student() {{ public Student() }}

public class Person {{ public class Person protected String name; protected String name; protected String imail; protected String imail; protected String homePage; protected String homePage; //// ////Navigation Navigation protected Course[] responsibleFor; protected Course[] responsibleFor; protected Course[] techResponsibleFor; protected Course[] techResponsibleFor; public Person() {{ public Person() }}

}}

}}

Itntroduction to UML by Jan Pettersen Nytun, page 9

A Class Diagram - Example With Interface


<<Interface>>

IStorable Register -reg 0..* edit() write() read()

relization
public void read(){ terminal.print("Name: "); name = terminal.readLine(); ... }

Person edit() write() read()

relization/implements
Person Register

To different representation of nearly the same dependency

Storable

edit() write() read()

Itntroduction to UML by Jan Pettersen Nytun, page 10

A Class Diagram One More Example With Interface

<<Interface >> ISortable Register


IStorable isLess(theOther : ISortable) : boolean isEqual(theOther : ISortable) : boolean isGreater(theOther : ISortable) : boolean

SortableRegister

Person

Itntroduction to UML by Jan Pettersen Nytun, page 11

3.3 Object Diagram Capture Instances and Links


Class
Company noOfEmploees : int Possible object

Object
HiA: Company
noOfEmploees=600

name attribute with value

object class

Itntroduction to UML by Jan Pettersen Nytun, page 12

Object Diagram with Links


Class Diagram
Company 1 1..* Department *

Object Diagram
Language:
Department :LocatedAt

Gimlemoen: Office

HiA: Company
LocatedAt Office 1..* Possible object diagram

Engineering :
Department

:LocatedAt

Grooseveien: Office

Link - A link is an instance of an association, analogous to an object being an instance of a class.


Itntroduction to UML by Jan Pettersen Nytun, page 13

Object diagram and Rational Rose 2000


Rational Rose 2000 does not have object diagrams, but you can achieve much the same with a collobartion diagram

noOfEmploees = 60 0

HiA:Co ma ny

Gim le mo en:Office

You can not specify attributes inside object; One solution to this short-coming is to use a comment!

Itntroduction to UML by Jan Pettersen Nytun, page 14

3.4 Sequence diagram


user
<command r> <name,e-mail,..>

controllerViewer

register

create
setData(name, ..)

person

insert(person)

Itntroduction to UML by Jan Pettersen Nytun, page 15

3.5 Colloboration diagram

1: register()

1.2: create 1.3: setDate(data)

user

controllerViewer
1.1: data := getData() 1.4: insert(person)

person

register

Itntroduction to UML by Jan Pettersen Nytun, page 16

3.6 Statechart diagram


Waiting do/ display("Off") exit/ display("Time?")

StateChart for microwave oven "control unit"

Power turned on

Set time

do/ get number exit/ ^timer.setTime(timeRead) [ Door closed ] [ Door open ]

Disabled do/ display("Close Door")

Door closed

Time out

Operating do/ display ("time left") exit/ ^heattingElement.powerOff() entry/ ^heatingElement.powerOn()

Door open
Simple microwave oven: - Power can be on or off - Time can be set after the power has been turned on

Itntroduction to UML by Jan Pettersen Nytun, page 17

Statechart for Applet


Not Loaded

init/init()

Running
stop/ stop() start/start()

Loaded start
/start()

destroy/destroy()

Stopped

Itntroduction to UML by Jan Pettersen Nytun, page 18

3.7 Activity diagram Capture Dynamic Behaviour (Activity-oriented)

Itntroduction to UML by Jan Pettersen Nytun, page 19

Activity diagram One More Example

activity product of activity

Itntroduction to UML by Jan Pettersen Nytun, page 20

Activity diagram - One More Example


user
request registration

controller

person

register

create person (object)

supply person-data

forward person-data

process person-data

insert person

Itntroduction to UML by Jan Pettersen Nytun, page 21

3.8 Component diagram Captures the Physical Structure of the Implementation


applet1.class applet1.java

Demo.html

applet2.class

applet2.java

logo.gif

Itntroduction to UML by Jan Pettersen Nytun, page 22

Component diagram One More Example


Person.class

Register.class

ISortable

Itntroduction to UML by Jan Pettersen Nytun, page 23

3.9 Deployment diagram


Extended VLAN Server

network LAN

PC

PC

Itntroduction to UML by Jan Pettersen Nytun, page 24

client:

browser:

Internet Internet

Multi-tier Architecture
view: browser/jsp/servlet controller: jsp/servlet model: businessObjects

- MVC -

server1:

:WebServer
:ServletContainer

:html :html

s1:Servlet

s2:Servlet

j1:Jsp

j2:Jsp

Intranet Intranet

b1:BusinessObject b2:BusinessObject

b3:BusinessObject b4:BusinessObject

server2:
:DB
Itntroduction to UML by Jan Pettersen Nytun, page 25

References
[1] Grady Booch, James Rumbaugh and Ivar Jacobson: The Unified Modeling Language User Guide. Addison-Wesley, 1999 James Rumbaugh, Michael Blaha, William Premerlani, Frederick Eddy and William Lorenzen: Object-Oriented Modeling and Design. Prentice Hall, 1991 Martin Fowler with Kendall Scott: UML Distilled. Addison-Wesley, 1997 Terry Quatrani: Visual Modeling with Rational Rose and UML. Addison-Wesley, 1998 Ari Jaaksi: A Method for Your First Object-Oriented Project. JOOP - The Journal of Object-Oriented Programming, Januar 1998 Rational software: http://www.rational.com/uml/documentation.html
Itntroduction to UML by Jan Pettersen Nytun, page 26

You might also like