1 Unified Modeling Language a language for specifying, constructing, visualizing and documenting the...

Post on 30-Dec-2015

224 views 3 download

Transcript of 1 Unified Modeling Language a language for specifying, constructing, visualizing and documenting the...

1

Unified Modeling Language

• a language for specifying, constructing, visualizing and documenting the artifacts of a software-intensive system– also for Business Modeling and other non-software systems

• Authors :Grady Booch, Jim Rumbaugh and Ivar Jacobson

• Stems out from : Booch, OMT, OOSE (and others)

2

• History

Booch method OMT

Unified Method 0.8OOPSLA ´95

OOSEOther methods

UML 0.9Web - June ´96

publicfeedback

Final submission to OMG, Sep ‘97

First submission to OMG, Jan ´97

UML 1.1OMG Acceptance, Nov 1997

UML 1.3

UML 1.0UML partners

Fragmentation

Unification

Standardization

Industrialization

3

• Goals• ready-to-use, expressive visual modeling language

• extensibility and specialization mechanisms to extend the core concepts

• independent of particular programming languages and development process

• formal basis for understanding the modeling language

• encourage the growth of the OO tools (CASE) market

• support higher-level development concepts such as collaboration, frameworks, patterns and components

• integrate best practices

4

• Outside the scope of UML– Programming languages

• the UML is a modeling language, not programming

• its aim is not to capture all necessary constructs of programming languages

– Tools• the UML defines a semantic metamodel, not an tool

interface, storage or run-time model– the UML documents do include some tips to tool vendors

(implementation choices), but do not address everything

– Process• the UML is intentionally process independent, and

defining a standard process was not a goal of UML– UML is a common language for priject artifacts, developed in

the context of different processes

5

• Artifacts– UML Semantics

• description of the UML metamodel, i.e. a model defining a language

– Abstract syntax

– Well formedness rules

– Semantics

– UML Notation Guide• graphical notation and textual syntax of “visual”

elements of the UML language

– UML Extensions• language extensions for Objectory Process, Business

Modeling, etc.

6

UML Generic mechanisms/Diagram elements• Graphs and their contents• Strings• Name• Label • Keywords

• Expression (OCL Expression)• Note• Type-instance correspondence

7

Graphs and their contents

UML diagrams are graphs containing nodes connected by paths. the information is mostly in the topology

(exception: a sequence diagram with a metric time axis)

• Graphical constructs used in UML notation: icon, two-dimensional symbols, drawing paths strings

8

Graphs and their contents

• Invisible hyperlinks and the role of tool a notation may contain additional invisible hyperlinks

that are not apparent in a static view a dynamic notation - out of scope of the UML

• Background information each appearance of a symbol may have its own

presentation choices information presented in a textual or tabular format presenting tabular information is a tool responsibility

(out of scope of UML)

9

Strings a sequence of characters they map underlying model strings, although some

strings may exist purely on the diagrams

Example– BankAccount– integrate (f: Function, from: Real, to: Real)

Name a string, that uniquely identifies a model element

within some scope a pathname = names linked by a delimiter (e.g. ‘::’)

Example– integrate– MathPak::Matrices::BandedMatrix.dimension

10

Label a string that is attached to a graphic symbol it is purely a notational term

Example

Keywords used to distinguish variations on a common theme general notation is : «keyword»

Example– <<stereotype>>

label

11

Expression expressed as strings in a particular language the OCL is used within the UML semantic

definition linguistic formulas yielding values

Example– BankAccount * (*) (Person*, int)– [ i > j and self.size > i ]

OCL Expression used to define constraints (within the UML

metamodel itself)

Example– flight.pilot.training_hours > flight.plane.minimum_hours– company.employees->select (title = ”Manager” and

self.reports->size > 10)

12

Note a graphical symbol containing textual

information a notation for rendering constraints,comments,

method bodies, and tagged values is a notational item

ExampleThis model was builtby Alan Wright aftermeeting with theplanning team.

13

Type-instance correspondence a major purpose of modeling is to prepare

generic descriptions that describe many specific particular items -> type-instance dichotomy

in UML the type-instance distinction is shown by employing the same symbol and by underlining the name string of an instance element.

ExamplePoint

x : Realy : Real

rotate(angle : Real)scale(factor : Real)

: Point

type

instance (object)

p1 : Point

- x : Real- y : Real

14

Generic mechanisms/Model management

Packages may contain packages and ordinary model elements some packages may be Subsystems or Models the basis for configuration control, access control element can be directly owned by a single package stereotypes system, facade, framework, top package the visibility (‘+’ public, ‘-’ private, ‘#’ protected) dependency between packages => dependencies

among the elements

15

Example (of packages)

Editor<<subsystem>>

Controler

Diagram Elements

Domain Elements

Graphics Core

package dependency

16

General extension mechanisms

represents general purpose mechanisms that may be applied to any modeling element

an extensibility device for UML

Constraint Comment Tagged values Stereotypes

17

• Constraint represents semantic information attached to a model

element - conditions to be maintained as true is shown as a text string in braces ( { } ) a predefined language for writing constraints is OCL a user-defined constraint is described in words in a

given language Stereotypes: <<invariant>>, <<postcondition>>,

<<precondition>>

Comment a text string attached directly to a model element. attaches arbitrary textual information to any model

element Stereotypes: <<requirement>>,<<responsibility>>

18

Example (constraints & comments)

CommitteePerson* *

1 *

* *

1 *

Member-of

Chair-of

{subset}

CompanyPerson

0..1*

employeremployee

0..1

*

boss

worker

0..1

* * 0..1

{Person.employer = Person.boss.employer}

Represents an incorporated entity

constraint

comment

19

Tagged values a mechanism to define new element

properties a property is a value attached to a model element

a keyword-value pair => tag-value

Example– { author = ”Joe Smith”, deadline = 31-March-1997, status

= analysis } or { abstract }

Stereotype built-in extensibility mechanisms of UML a new class (subclass of an existing ) of

modelling elements introduced at modelling time

notation a key-word string (within guillemets,e.g. «foo».) a special graphic icon

20

Example (of stereotypes)

Place order

Order product Arrange payment

<<uses>>

<<uses>>

PenTracker

PenTracker

location : Point

enable(Mode)

<<UML control>>

Model View Controller

21

Static structure diagrams

• Class diagrams show the static structure of the model, contain classes, interfaces, packages,

relationships also known as “static structural diagrams” are organized into packages

• Static object diagram a graph of instances an instance of a class diagram - a snapshot of

the state of a system at a point in time shows examples of data structures

22

Concepts to be discusssed Class

• Attribute and Operation

• Interface, Parameterized class, Utility

Type vs. Implementation class Importing a package Object {Bin, N}-ary Association

• Association end, Aggregation, Composition, Multiplicity, Qualifier, Association class

Generalization Dependency Derived element

23

Class the descriptor for a set of objects with similar

structure, behavior, and relationships represents a concept within the modeled

system classes have data structure and behavior and

relationships to other elements the name of a class has scope within the

package in which it is declared => the name must be unique

Notation rectangle with 3 compartments

name and general properties, attributes, operations

a reference to a class => Package-name::Class-name

24

Example (of classes)

Window

size : Area = (100,100)visibility : Boolean = invisible$ default-size : Rectangle$ maximum-size : Rectanglexptr : XWindow*

display()hide()<<class>> create()attachXWindow(xwin : XWindow*)

Window

size : Area = (100,100)visibility : Boolean = invisible

display()hide()

Window(standard) list compartment

name compartment

(user defined) list compartment

25

Attribute is semantically equivalent to a composition

association (the intent and usage is normally different)

Notationvisibility name [multiplicity]: type = default {property-

string} visibility = {+ public, # protected, - private} property-string indicates property values, e.g.

{frozen} - a nonchangeable attribute

a class-scope attribute - underlined or preceded with $

multiplicity if absent an attribute holds exactly 1 value e.g. name [0..1]: String (permits a distinction between the

null value and the empty string)

26

Operation a service that an instance of the class may be

requested to perform

Notationvisibility name ( parameter-list ) : return {property-

string} parameter-list is a comma-separated list of

kind name : type-expression = default-value kind is in, out, or inout, with the default in if absent

property-string indicates property values, e.g. {query} - operation does not modify the system state {sequential}, {guarded}, {concurrent} {abstract} - the class does not implement the

operation

stereotype «signal» indicates that the class accepts the given signal (with operation name)

27

Type vs. Implementation class Type

is a specification of externally visible behavior of a set of objects

Implementation Class defines the physical data structure and

procedures of an object

an object may have multiple Types but only one Implementation Class (which is fixed)

the implementation of a type by an implementation class is modeled as the Realizes relationship (this implies inheritence of operations, not of structure)

28

Example (of a type and impl. class)

Collection<<type>>

Set

elements : Collection

addElement(Object)removeElement(Object)testElement(Object) : Boolean

<<type>>

HashTable<<implementation class>>

HashTableSet

elements : Collection

addElement(Object)removeElement(Object)testElement(Object) : BooleansetTableSize(Integer)

<<implementation class>>

29

Interface is a specifier for the externally-visible

operations of a class, component, or other entity (e.g. packages)

does not have implementation may have generalization relationships

Example

Hashable

Comparable

HashTableString

isEqual(String) : Booleanhash() : Integer

*

contents

*

Comparable

isEqual()hash()

<<Interface>><<uses>>

30

Parameterized class & Bound element Template

the descriptor for a class with unbound formal parameters

defines a family of classes (but, is not a directly-usable class)

attributes and operations are defined in terms of the parameters

Bound element template’s parameters are bound to actual

values. fully specified by its template (content may not

be extended)

Example

T, k

FArray

items[k] : T

FArray<Point, 3>AddressList

(Address, 24)

<<bind>>

31

Utility is a grouping of global variables and

procedures attributes and operations are interpreted as

being at class scope

Example

• Metaclass is a class whose instances are classes shown as the stereotype «metaclass» of

Class

MathPak

sin()cos()sqrt()random()

32

Importing a package the contents of the target packages (and

its sub-packages) may be referenced by the client package

does not modify the namespace of the client

the visibilities are combined according to the rule that the most restrictive visibility in the set is obtained

represented by «imports» dependency relation

ExampleCustomers Banking

CheckingAcount

<<import>>

CheckingAcount(f rom Banking)

33

Object represents a particular instance of a class has identity and attribute values

Example

p1 : Point

- x : Real- y : Real

: Point

34

Binary Association is an association among exactly two

classes (including a reflexive association) predefined constraints, e.g. {or}

Notation consists of

association ends (2), name, association class (optional)

Example

Corporation

Account

Person

{or}

PersonCompany* 1..*

employer employee

1..**

Job

salary

0..1

*

boss

worker

0..1

* Manages

35

Association end an end of an association where it connects to a

class each association has two or more ends

Notation kinds of adornments of an association end:

multiplicity ordering

the set of related elements can be {ordered},{unordered}

qualifier navigability aggregation (a diamond) rolename

indicates the role played by the class changeability of the links, e.g. {frozen} or {addOnly} visibility

36

Aggregation and composition aggregation (a diamond)

a whole-part relationship also treated as an ownership by reference

composition (a filled-diamond aggregation with strong ownership and

coincident lifetime as part of the whole parts :

may be created after the composite itself they live and die within the whole can be explicitly removed before the death of the

whole the multiplicity of the aggregate end may not

exceed one (it is unshared) also treated as an ownership by value

37

Example (of an aggregation and composition)

PointPolygon

3..n1

+points

3..n{ordered}

1

Contains

GraphicsBundle

1

11

1

-bundleSlider Header

Window

2

1

1

1

Panel1

11 11

scrollbar

2title 1

1

body

38

Multiplicity specifies the range of allowable cardinalities that

a set may assume a comma-separated sequence of integer intervals

lower-bound .. upper-bound, a number, * - many

Qualifier an attribute or list of attributes whose values

serve to partition the set of objects associated with an object across an association

multiplicity “0..1” - a unique value may be selected, but every

possible qualifier value does not necessarily select a value

“1” - every possible qualifier value selects a unique target

“*” - the qualifier value is an index that partitions the target objects into subsets

39

Example (of a qualifier)

Bank

Person0..1

account #

*

0..1

account #

*

Chessboard

Square1

rank : Rankfile : File

1

rank : Rankfile : File

1

1

40

Association class an association that also has class

properties it is a single model element (association

+ linked class)

ExampleCompany Person

* 1..*

employer

*

employee

1..*

Job

salary

0..1

*

boss0..1

Manages

worker

*

41

N-ary association an association among 3 or more classes may not contain the aggregation marker

Example This example shows the record of a team in each

season with a particular goalkeeper.The goalkeeper might be traded during the season and can therefore appear with different teams.

42

Generalization taxonomic relationship between a more general

element and a more specific element that is fully consistent with the first element and that adds additional information.

Notation discriminator

the name of a partition of the subtypes of the superclass.

constraints {overlapping} - inheritence from more subclasses

allowed {disjoint} - inheritence from more subclasses NOT

allowed {complete} - all subclasses have been specified {incomplete} - there are additional subclasses that are

not yet in the model

43

Example (of a generalization)

Shape

Polygon Ellipse Spline

{disjoint}

Vehicle

WindPoweredVehicle MotorPoweredVehicle

LandVehicleWaterVehicle

power

venue

power

venue

{overlapping}

{overlapping}

SailBoat Truck

44

Dependency indicates a semantic relationship between

two (or more) model elements predefined kinds

trace - connects the same concept at different levels of meaning (history)

refine uses - operation calling, instantiating, etc. bind - binding of template parameters to actual

values

Example ClassA ClassB

ClassC

<<friend>>

<<instantiates>><<calls>>

45

Derived element is one that can be computed from

another one is shown for clarity or for design purposes adds no semantic information

Example

1

*

{age = currenntDate - birthdate}Person

birthdate/ age

DepartmentCompany

*1 *

employer

1

Person*

1

*

department1

WorksForDepartment

+employer1

*

/WorksForCompany

{Person.employer = Person.department.employer}

46

Process of static structure modelling Identify classes

from Glossary from Business Model stored information items from use case realizations

Specify the semantics of classes responsibility attributes, operations and interfaces

Identify relationships among classes domain based associations object interactions generalization and aggregation relationships

Structure the model into packages

47

Interaction diagrams

• Sequence siagrams

• Collaboration diagram show a pattern of interaction among objects they express similar information but show

it in different ways

• Multiobject

• Message flow

48

Sequence siagrams show an interaction arranged in time sequence

show the sequence of messages exchanged among objects

for real-time specifications and complex scenarios

Collaboration diagram represents a Collaboration and an Interaction Collaboration

a set of objects related in a particular context context is a collaboration diagram without messages

Interaction a set of messages exchanged among the objects within

a collaboration to effect a desired operation or result.

shows an interaction organized around the objects does not show time as a separate dimension may be attached to an operation or a use case

49

Example (of a scenario diagram)

caller : Person receiver : Person

exchange : EWSD

1. lift receiver

1.1. dial tone

2. dial digit

a

b

c

3. route

...

3.2. ringig phone

3.1. phone rings

4. answer pgone

4.2. stop tone

4.1. stop ringing

d

d'

{b-a < 1 sec.}

{c-b < 10 sec.}

The call is routed through network

{d'-d < 5 sec.}

At this point the parties cam talk.

50

Example (of a collaboration diagram)

caller : Person

exchange : EWSD

receiver : Person

1. lift receiver

2. dial tone

3. dial digit4. route

6. ringing phone9. stop tone

5. phone rings

7. answer phone 8. stop ringing

51

Multiobject represents a set of objects used to show operations that address the

entire set, rather than a single object in it

Example

client : Client

: Server

: Server

servers

1. aServer:=find(specs)

L

aServer

2. process(request)

F

52

Message flow the sending of a message from one object to

another shown as a labeled arrow placed near a link kinds of messages (control flow type)

procedure call, asynchronous, synchronous balking, time-out, ...

Notationpredecessor guard sequence-expression iteration

return-value := message-name argument-ist predecessor - list of sequence numbers

the message flow is not enabled until all of the listed messages have occured

represents a synchronization of threads

gurad - condition clause iteration - *[iteration clause]

53

Example (of message flows) 2: display (x, y) simple message 1.3.1: p:= find(specs) nested call with

return value [x < 0] 4: invert (x, color) conditional message A3,B4/ C3.1*: update ()

synchronization,iteration

54

Process of interaction modeling Identify objects participating in the collaboration Trace an interaction (scenario or algorithm) and add

messages and links Specify synchronization (if needed)

55

Statechart diagrams

• State

• Composite states

• Event

• Simple and complex transitions

• History

56

Statechart diagram shows the sequences of states that an

object goes through during its life in response to received stimuli

a state machine is attached to a class or a method

Example

Locked Unlocked

Coin / Unlock

Pass / Lock

Subway Turnstile :

57

State a condition during the life of an object during which

performs some action, or waits for some event

Notation name internal transitions

activities performed in response to events received while the object is in the state, without changing state

event-name argument-list [condition ] / action special (predefined) events

entry / action action performed on entry to the state

exit / action action performed on exit from the state

do / action action performed during the state action

action name ^target.event(arguments)

58

Example (of states)

Typing password

entry: set echo invisibleexit: set echo normalon character: handle characteron help: display helpdo: type

Initial state

Final state

59

Composite states a state can be decomposed using (one of

these) and-relationships into concurrent substates or-relationships into mutually exclusive

disjoint substates

60

Example (of composite states)

Dialing

Start

entry: start dial toneexit: stop dial tone

Partial dial

entry: number.append(n)

Start

entry: start dial toneexit: stop dial tone

Partial dial

entry: number.append(n)

digit( n )

digit( n )

[ number.isValid() ]

61

Event an occurrence that may trigger a state

transition kinds of events

ChangeEvent -occurs whenever the value of the expression changes from false to true

SignalEvent - receipt of an explicit signal CallEvent - receipt of a call for an operation TimeEvent - passage of a designated period of

time

Notation event-name ( parameter-list)

Example when (balance < 0) after (5 seconds)

62

Simple transition a relationship between two states indicating

that an object in the first state will enter the second state and perform certain specified actions when a specified event occurs if specified conditions are satisfied

the trigger for a transition is the occurrence of the event labeling the transition

Notationeven( parameters) [condition ] / action

target.event(parameters)

Example right-mouse-down (location) [location in window] /

object := pick-object (location)^ object.highlight ()

63

Complex transition may have multiple source states and

target states represents a synchronization and/or a

splitting of control into concurrent threads without concurrent substates

is enabled when all of the source states are occupied

fires all of its destination states are occupied

ExampleSetup

A1 A2

B1 B2

A1 A2

B1 B2

Cleanup

64

History a state region may contain a history state

indicator may have any number of incoming transitions may have at most one outgoing unlabeled

transition (default “previous state”)

transition to the history indicator indicates that the object resumes the state it last had within the complex region

kinds of history indicator shallow history

object resumes the state it last had at the same level as the history indicator

deep history (indicated by H*) object resumes the state it last had at any

depth

65

Example (of a history)

A A1

A2H

A1

A2H

Cinterrupt

resume

66

Process of statechart modeling Identify states Identify external events which can cause change of

status To each state attach transitions based on events Add transition and internal actions Identify AND/OR substates

67

Activity diagrams

• Action state

• Decision and Merge• Swimlanes

• Object flow relationship

• Controll icons

68

Activity diagram a variation of a state machine in which the states

are Activities representing the performance of operations and the transitions are triggered by the completion of the operations

is attached to a class or to the implementation of an operation or a use case

the purpose is to focus on flows driven by internal processing (as opposed to external events)

use activity diagrams in situations where all of the events represent the completion of internally-generated actions (that is, procedural flow of control)

use ordinary state diagrams in situations where asynchronous events occur

69

Example (of an activity diagram)

Find Beverage

Pour Coffee Drink Beverage

Get Can of ColaGet CupsAdd Water to Put Coffee in Filter

Put Fil ter in

Turn on

Brew Coffee

^coffeePot.TurnOn

[ no cola ]

[ found cola ]

Person::Prepare Beverage

[ no coffee ]

[ found coffee ]

light goes out

70

• Action state a state with an internal action and at

least one outgoing transition representing the completion of the action

should not have internal transitions or outgoing transitions based on explicit events

the normal use is to model a step of an algorithm

Action represented by an action-expression may use only attributes and links of the

owning object

71

Decision and Merge Decision

branching of transitions based on boolean conditions may have a predefined guard "else" transitions from the decision may not have an event

trigger

Merge used to merge decision branches back

together

ExampleCalculate total cost

Get authorization[ cost < $50 ]

[ cost >= $50 ]Charge customer's account

72

Swimlanes actions may be organized into swimlanes kind of package for organizing responsibility

for activities within a class often correspond to organizational units in a

business model

Object flow relationship objects that are input to or output by an

action may be shown as object symbols the control flow (solid) arrows is omitted when

the object flow (dashed) arrows is specified frequently the same object is manipulated by

a number of successive activities to distinguish its various appearances, the state of

the object may be supplied (in [ ])

73

Example (of swimlanes and object flow)

74

Controll icons provide explicit symbols for certain kinds of

information that can be specified on transitions are not necessary for constructing activity

diagrams Signal receipt

a dashed arrow may be drawn from the sender

Signal sending A dashed arrow may be drawn from to the receiver

Deffered event an event that occurs must be “deferred” for later use

(durig some activity; normally an event that is not handled immediately is lost.)

each state or activity specifies a set of events that are deferred

is shown within the state followed by “/ defer”

75

Example (of control icons)

Object - CoffeePot

Turn on

Brew Coffee

Pour Coffee

turn on

light goes out

Turn on

Brew Coffee

on light goes out: /defer

Pour Coffee

turn on

light goes out

Get cups

on light goes out: /defer

76

Implementation diagrams

• Component diagram– Component

• Deployment diagram– Processor– Device– Connection

77

Component diagram shows the dependencies among software

components, including source code components, binary code components, and executable components.

Component represents a distributable piece of implementation

of a system, including software code (source, binary, or executable) but also including business documents, etc., in a human system.

Stereotypes: <<document>> <<executable>> <<file>> <<library>> <<table>>

78

Example (of component diagram)

Scheduler

Planner

GUI

update

reservations

ActiveX Package

<<ActiveX>>

Task Body

Task Specification

79

Deployment diagram shows the configuration of run-time

processing elements and the software components, processes, and objects that live on them

Processor a piece of HW capable to execute programs may show a list of processes

Device a piece of HW incapable of executing programs

Connection HW (physical) connection between two nodes the type of communication can be specified by a

stereotype, e.g. <<TCP/IP>>

80

Example (of a deployment diagram)

Databse Server

PC1

Order entryPC2

Planning

PC3

Backup Device

81

Links– www.rational.com

– www.omg.org

82

Stereotypes prevent explosion of modeling elements

in UML adding of semantically new elements,

whithout changing the language apply to model elements, not to instances extensions to modeling language, not

runtime environment

83

Stereotypable Elements• Static/Structure

– Association (implicit,local, global,…)– Generalization (implementation)– Dependency, Usage (call, create, send, instantiate),

Abstraction (derive, realize, refine)– Class (type, interface, utility …), Attribute– Component (document, file, exe, library,…)

• Behavior– Method/Operation (create, destroy)– Collaborations, Flow, Interaction– Use cases– States (activity)

• Supplementary– Comment– Constraint

84

ProcessSearch

searchWord : StringsearchDescription : String

nl : StringMassagedWord : String

Browsing

String-Util

ForHTML()

EntryListing

SearchResults

spErrorMsg

Main()

GetEntries

<<build>>

25

+LetterEntry

25<<link>>

{BeginWith}

<<redirect>>{ErrDescription}

<<build>>

<<redirect>{ErrDescription}

GlossaryHome

26

+LetterEntry

26

<<link>>

{BeginWith}

SearchForm<<submit>>

<<include>>

Client page Server page

Form

85

86

87

88

Business Modeling Extension

89

Soft. Development Processes Extension