Top Banner
UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams
51

UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

Dec 22, 2015

Download

Documents

Kory Nelson
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

UML Notations

Activity diagramsState diagramsClass diagrams

Use-case diagrams

Page 2: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

2UML notations

Background UML

• Unified Modeling Language (UML) is a standard language for specifying, visualizing , and constructing, and documenting the artifacts of software systems.– http://www.uml.org/

• UML represents the collection of best engineering practices, mainly used for object oriented software development

• UML uses graphical notations to express the design of software projects.

Page 3: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

Goals of UML

• Provide users with a ready-to-use visual modeling language to exchange meaningful models

• Provide extensibility and specialization mechanisms to extend the core concepts

• Be independent of particular programming languages and development processes.

• The development of UML began in 1994 by Grady Booch and Jim Rumbaugh from Rational Software Corporation

Page 4: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

4UML notations

UML Diagrams

• Activity diagram– combined function/control view

• State diagram– highly interactive control

• Class diagram– static information structure (“data”)

• Use-case diagram– high level view of system services (functional)

Page 5: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

5UML notations

Activity diagram

• Model control and information flow of a procedure or process

• It describes the state of activities by showing the sequence of activities performed.

Page 6: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

6UML notations

Action state

• State in which some work is being done– activity, task

• State terminates when the work is finished– difference with state diagrams

• After termination the action state can lead to another action state– “state transition”

• Special symbols for being and end of a procedure or process

Page 7: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

7UML notations

Basic notation for activity diagram

data entry

processinggenerateoutput

Page 8: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

8UML notations

Decision

• State transition is deterministic• If transition depends on outcome of the work,

then introduces a decision

data entry

dump in waste basket

furtherprocessing

[data correct]

[data incorrect]

Page 9: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

9UML notations

Introducing concurrencybuy food

and drinks

cook dinneropen wine

bottle

have dinner

Page 10: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

10UML notations

Swim lanes

• Process can sometimes be distributed over several agents or organizational units

• Notation: use compartments• Use to model a business process (e.g. in

organization model)

Page 11: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

11UML notations

Notation for swim lanes

write tender

get customerinformation

SALESDEPARTMENT

calculatecost

DESIGNDEPARTMENT

designelevator

Page 12: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

12UML notations

Object flow

standarddesign

write tender

get customerinformation

SALESDEPARTMENT

decide about design type

customdesign

costcalculation

elevatordesign

DESIGNDEPARTMENT

non-standard standard

CUSTOMER

tender

customerinformation

Page 13: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

13UML notations

Business process “Housing”primaryprocess

secondaryprocess

data entryof applications

magazineproduction

applicationassessment

residenceassignment

statisticalanalysis

policyinformation

:residenceassignments

Page 14: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

14UML notations

State diagrams

• Synonyms: “state chart”, “state-transition diagram”

• Purpose: model of dynamic behavior• Use if control is heavily influenced by

“external” events

Page 15: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

15UML notations

State

watching football match

duration

entry/switch on TVdo/watchexit/turn off TV

state name

state variables

state actions& activities

Page 16: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

16UML notations

State transition

• Event: comes from outside the object modeled• Message: generates event for another object• Guard: outcome of internal object computation

ready fortake off

check: boolean

entry/final check

airborne

do/fly

permission-from-control-tower[check -= OK] / take-off control-tower.confirm-takeoff(flightID)

Page 17: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

17UML notations

Actions and activities

• Action: instantaneous, not interruptible– on transition– on state entry = action on all incoming transitions– on state exit = action on all outgoing transitions – on event

• Activity: takes time, interruptible

Page 18: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

18UML notations

State diagram of ticket machine

idle inserting money

timerbalance

insert(coin)/add to balance

processing selection

do/compute change

dispensingchange

do/dispense change

dispensingticket

do/dispense ticket

cancelling

do/return balanceselect(ticket)

cancel buttonpressed

time out

[balance < ticket price]

insert(coin)/new balance

[balance = ticket price]

[balance > ticket price]

Page 19: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

19UML notations

State concurrencyentering

transactiondata

processing

take outcash

take outcard

idle

cash cardentered

cash taken card taken

Page 20: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

20UML notations

State diagram “Housing”

applicationassessment

waiting for case data

application received/order assessment

data needed/ask

data received / reply

assessment finished/report decision

Page 21: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

21UML notations

Class diagram

• Describe the types of objects in a system and their relationships

• Model class structure and contents• Class has three things: a name, attribute, and

operations

Page 22: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

22UML notations

Objects and classes

Fokker 100:airplane

airplane

#seats: integer

Fokker 70:airplane

#seats = 80

:airplane

Page 23: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

23UML notations

Object class

• Describes a group of objects with similar properties– Abbreviation: "class"

• Rationale for introducing classes: – it provides a means for abstraction

• Terminology: “object” is often used in an ambiguous way, pointing to both objects (in the strict sense) and object classes.

Page 24: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

24UML notations

Attributes

• An attribute describes a value held by objects belonging to the class.

• Attribute specification consists of:– Class it is defined on (student)– Attribute name (name)– Admissible values (string)– Optional: default value

Page 25: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

25UML notations

Values and Value Sets

• Values are the primitive things with no internal structure from the viewpoint of the application

• Admissible values are defined through a value set

• Typical predefined value-sets:– string, number, integer, real, range, boolean, ….

• User-defined:– set or list of strings

Page 26: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

26UML notations

Object Identifiers

• In O-O modeling you assume that every object has an identity.

• Consequence: introduce only attributes that act as identifiers, iff the identifier is something that exists in the real world.

• Examples: student card number, social security number.

Page 27: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

27UML notations

Operations

• Definition: – operation is "a function or a transformation that

can be applied to objects of a class".• Objects in a class share the same operations.• Method: implementation of an operation

Page 28: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

28UML notations

Class notationclass name

attribute-1: value-setattribute-2: value-set

operation-1(Par1:Type, Par2:Type): ReturnType

library book

catalog#: stringtitle: stringauthor: stringcategory: Categorycover-type: {hard-cover, paperback}

available(): Boolean

librarybook

Page 29: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

29UML notations

Associations

• Associations are used to link objects to other objects

• Majority of associations:– binary (between two objects)– directional (should be read in a particular direction

• Ternary associations come up occasionally.• Associations between more than three objects

are rare.

Page 30: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

30UML notations

Association notation

man woman0-1 0-1

wifehusband

man womanhusband wife

married-to

General notation for association

Notation for a binary association

married-to 0-10-1

Page 31: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

31UML notations

Multiplicity examples

student course

person

major

address<< has address

married-to

major subject >>

enrolled in >>

0+

0-1

1+

Page 32: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

32UML notations

Multiplicity

• Also called: "cardinality".• Always connected to one of the classes

involved.• Typical types of multiplicity:– 0-1 Zero or one (optional).– 1 Precisely one.– 0+ Zero or more,– 1+ One or more.

Page 33: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

33UML notations

Association class

• Modeling an association as a class if the association has an internal information structure

• Advantage: associations become first-class objects.

• Attributes and methods can be defined for the association class.

Page 34: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

34UML notations

Notation association class

man woman0-1 0-1

wifehusband

marriage

date: Date

cityregistered in >>

Page 35: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

35UML notations

Use of an association classcompany

name

person

namesocial security #addresssalaryjob title

person

namesocial security #address

company

name

<< works for

employer employee

1+1

employer employee

1+ 1+

works for

salary:job title

if you want to model thata person can work for

more than one company,then change to

Page 36: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

36UML notations

Associations with specific semantics

• Associations provide a general, "neutral", way of connecting object classes.

• Semantics of the association are defined through argument typing, multiplicity and (implicitly) the name of the association.

• Class diagrams provide specific types of associations, with predefined semantics:– generalization ("is a").– aggregation ("part of").

Page 37: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

37UML notations

Generalization

• Purpose: sharing similarities while preserving differences

• Is an association between a class that acts as super-class and one or more classes called the sub-classes.

• Super-classes show the features that the sub-classes have in common.

• Each sub-class inherits the attributes and operations defined on its super-class(es).

Page 38: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

38UML notations

Notation for generalizationagent

humancomputerprogram

man woman

taskexecutor-of >>

1+ 0+

Page 39: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

39UML notations

Aggregation

• Aggregation denotes a binary association in which one side is an "assembly" and the other side a "part".

• "Assembly" and "part" act as predefined roles involved in the aggregation association.

• Cardinality of a part can be defined – precisely one; optional (0-1); many, ...

Page 40: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

40UML notations

Notation for aggregationaudiosystem

tape deck

CD player

tuner

amplifier

speakerheadphones

recordplayer

0-1

0-1

0-1

0-1 0-1 2,4

Page 41: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

41UML notations

Composition

• Sub-type of aggregation• Existence of part depends on aggregate

document

nametype

openprint

paragraph

style0+

Page 42: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

42UML notations

Aggregation and generalization

• Similarities:– Tree-like structure

• Differences:– AND-tree (aggregation) vs. OR-tree

(generalization)– instance tree (aggregation) vs. class tree

(generalization)

Page 43: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

43UML notations

Combined aggregation and generalization

audiosystem

tape deck

CD player

tuner

amplifier

speakerheadphones

recordplayer

0-1 2,4input

system

1+

Page 44: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

44UML notations

Use-case diagram

• shows services that can be expected from a system

• provides outsider view (customer)• terminology

use case service provided by systemactor agent using a system service

• used in early phases of system analysis

Page 45: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

45UML notations

Use cases for a librarylibrary system

lend book

make bookreservation

search librarycatalog

add bookto catalog

remove bookfrom cataloglender librarian

Page 46: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

46UML notations

A small case study

• Course administration system (CAS)• Context: university department• Required services:

STUDENT: update personal data, inspect exam results, inspect course info, enroll in course

TUTOR: inspect exam results, update course info, inspect enrollments

ADMIN STAFF: enter exam results, inspect exam results, update personal data students, inspect enrollments

Page 47: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

47UML notations

Use cases

student

tutor

updatestudent data

inspectcourse info

updatecourse info

enrollin course

enterexam results

browseenrollments

browseexam results

browseindividual

results

browsecourseresults

administrativestaff

Page 48: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

48UML notations

Class diagram

student

student-card#: stringname: stringaddress: stringdate-of-birth: datamajor: Major.........

course

course-code: stringyear: integertrimester: 1-3study-points: integerlearning-goals: stringdescription: textliterature: textmaximum-#students: integer

exam

date: dateresult: [0..10]

enrollment

date: date

universitystaff member

title: stringposition: stringdepartment: stringtelephone: stringroom: stringe-mail: string

0+ 0+

course-exam1

0+

tutor

0+

1+

0+

requires

Page 49: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

49UML notations

Activity diagram for course enrollment procedure

submitenrollment

request

checkstudent limit

checkpreconditions

inform aboutprerequisites

inform aboutstudent limit

registerenrollment

inform aboutenrollment

[preconditionsOK]

[preconditionsnot OK] [above limit]

[limit notyet reached]

Page 50: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

50UML notations

State diagram:“update student data”

waiting fornotification

timer

received(new student data) send message to

central university database

localprocessing

do/update local databasedo/display results

OK message received from central database

[timer = time-out or not OK]/notify failure

Page 51: UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.

Tools to draw UML

• Powerpoint• MS Visio: http://www.youtube.com/watch?

v=FPB0Tw9jFE8• Online: – http://creately.com/Draw-UML-and-Class-Diagram

s-Online– http://www.gliffy.com/uses/uml-software/