02291: System IntegrationUML Diagrams (II) I Behaviour Diagrams I Use-Case Diagram I How users...

17
02291: System Integration Introduction to UML Hubert Baumeister [email protected] DTU Compute Technical University of Denmark Spring 2020

Transcript of 02291: System IntegrationUML Diagrams (II) I Behaviour Diagrams I Use-Case Diagram I How users...

Page 1: 02291: System IntegrationUML Diagrams (II) I Behaviour Diagrams I Use-Case Diagram I How users interact with a system I Activity Diagram I Procedural and parallel behaviour I State

02291: System IntegrationIntroduction to UML

Hubert [email protected]

DTU ComputeTechnical University of Denmark

Spring 2020

Page 2: 02291: System IntegrationUML Diagrams (II) I Behaviour Diagrams I Use-Case Diagram I How users interact with a system I Activity Diagram I Procedural and parallel behaviour I State

What is the UML?

I Unified Modelling Language (UML)I Family of graphical notations for describing aspects of

(object-oriented) softwareI ”A picture is more than a thousand words”

I UML is an open standard and an ISO standardI managed by the Object Management Group

(www.omg.org)I Web resources

I http://www.uml.org

Page 3: 02291: System IntegrationUML Diagrams (II) I Behaviour Diagrams I Use-Case Diagram I How users interact with a system I Activity Diagram I Procedural and parallel behaviour I State

Example of a class diagram

{pre: bor.canBorrow() post: dueDate = Date.today + 3 weeks and bor.books->containing(self) }

{body: books->size <= 5 and books->forAll(b | not(b.overdue))}

<<inter face>>LibraryInterface

scanLibraryCard()checkOutscanBook()checkIn...

{inv: overdue iff dueDate <> null and today > dueDate}

BookoverduedueDateregister()deregister()checkout()checkin()

Borrower

canBorrow()

Library

scan library card()check outscan book()check in...

0..5*

user

*

Page 4: 02291: System IntegrationUML Diagrams (II) I Behaviour Diagrams I Use-Case Diagram I How users interact with a system I Activity Diagram I Procedural and parallel behaviour I State

Metamodel Excerpt

UML Superstructure Specification, v2.4.1 29

Figure 7.12 - Classes diagram of the Kernel package

Classifier

Class

Operation

Classifier

StructuralFeature

Association+ isDerived : Boolean = false

ClassifierRelationship

ValueSpecification

Type

Property+ isDerived : Boolean = false+ isReadOnly : Boolean = false {redefines isReadOnly}+ isDerivedUnion : Boolean = false+ /default : String [0..1]+ aggregation : AggregationKind = none+ /isComposite : Boolean+ isID : Boolean = false

«enumeration»AggregationKind

nonesharedcomposite

* + class

* + /superClass

{subsets classifier}

{redefines general}

0..1

+ class

*

+ ownedOperation

{subsets featuringClassifier,subsets redefinitionContext,subsets namespace}

{ordered, subsets feature,subsets redefinableElement,subsets ownedMember}

0..1

+ class

*

+ nestedClassifier

{subsets namespace, subsetsredefinitionContext}

{ordered, subsets ownedMember,subsets redefinableElement}

0..1 + association

*+ navigableOwnedEnd

{subsets owningAssociation}

{subsets ownedEnd}

0..1

+ owningAssociation

*

+ ownedEnd

{subsets association,subsets featuringClassifier,subsets namespace, subsetsredefinitionContext}

{ordered, subsets memberEnd, subsets feature,subsets ownedMember, subsets redefinableElement}

0..1

+ association

2..* + memberEnd

{subsets memberNamespace}

{ordered, subsets member}

0..1+ owningProperty

0..1

+ defaultValue

{subsets owner}

{subsets ownedElement}

*

+ association

1..*

+ /endType{subsets relationship}

{ordered, readOnly,subsets relatedElement}

0..1 + class

*

+ ownedAttribute

{subsets classifier, subsets namespace}

{ordered, subsets attribute,subsets ownedMember}

**

+ subsettedProperty

0..1 0..1 + /opposite

*

+ property

*

+ redefinedProperty

{subsets redefinableElement}

{subsets redefinedElement}

{pre: bor.canBorrow() post: dueDate = Date.today + 3 weeks and bor.books->containing(self) }

{body: books->size <= 5 and books->forAll(b | not(b.overdue))}

<<inter face>>LibraryInterface

scanLibraryCard()checkOutscanBook()checkIn...

{inv: overdue iff dueDate <> null and today > dueDate}

BookoverduedueDateregister()deregister()checkout()checkin()

Borrower

canBorrow()

Library

scan library card()check outscan book()check in...

0..5*

user

*

Page 5: 02291: System IntegrationUML Diagrams (II) I Behaviour Diagrams I Use-Case Diagram I How users interact with a system I Activity Diagram I Procedural and parallel behaviour I State

The meaning of UML

I The abstract syntax / concepts: OKI Metamodel concepts of UML elements

I e.g. class, association, . . .I Metamodel written in MOF (Meta-Object Facility)

I Basically UML class diagrams→ MOF can be used to defined ones own modelling language→ Course Software Engineering II (02162)

I The meaning of the concepts: not well-definedI Meaning of class?I Execution of activity diagrams and state machines

Page 6: 02291: System IntegrationUML Diagrams (II) I Behaviour Diagrams I Use-Case Diagram I How users interact with a system I Activity Diagram I Procedural and parallel behaviour I State

Ways of using the UML

I SketchI Informal use→ Use of whiteboards, simple graphic editors

I BlueprintI Forward Engineering: e.g. create class stubs→ Use of CASE tools

I Programming languageI Executable UMLI Problems

I How to describe the behaviour?

→ Use of CASE tools

Page 7: 02291: System IntegrationUML Diagrams (II) I Behaviour Diagrams I Use-Case Diagram I How users interact with a system I Activity Diagram I Procedural and parallel behaviour I State

UML Diagrams (I)

I Structure DiagramsI Class Diagram

I Class, features, and relationshipsI Object Diagram

I Example configuration of instancesI Package Diagram

I Hierarchical structure for modelsI Component Diagram

I Structure and connections of componentsI Deployment Diagram

I Deployment of artifacts to nodesI Composite Structure Diagram

I Runtime decomposition of a class

Page 8: 02291: System IntegrationUML Diagrams (II) I Behaviour Diagrams I Use-Case Diagram I How users interact with a system I Activity Diagram I Procedural and parallel behaviour I State

UML Diagrams (II)

I Behaviour DiagramsI Use-Case Diagram

I How users interact with a systemI Activity Diagram

I Procedural and parallel behaviourI State Machine Diagram

I How events change an object over its lifeI Interaction Diagram

I Sequence Diagram: Interaction between objects; emphasison sequence

I Communication Diagram (formerly called collaborationdiagram): Interaction between objects; emphasis on links

I Interaction Overview Diagram: Mix of sequence and activitydiagram

I Timing Diagram: Interaction between objects; emphasis ontiming

Page 9: 02291: System IntegrationUML Diagrams (II) I Behaviour Diagrams I Use-Case Diagram I How users interact with a system I Activity Diagram I Procedural and parallel behaviour I State

Focus of the course

One car, many models (abstractions)

Page 10: 02291: System IntegrationUML Diagrams (II) I Behaviour Diagrams I Use-Case Diagram I How users interact with a system I Activity Diagram I Procedural and parallel behaviour I State

Focus of the courseOne system, many models (abstractions)

Different Views on the systemI Functionality: Use Case diagram, state machines, activity

diagram, . . .I Structure: Component diagram, Class diagramI Validation: Interaction diagram

Page 11: 02291: System IntegrationUML Diagrams (II) I Behaviour Diagrams I Use-Case Diagram I How users interact with a system I Activity Diagram I Procedural and parallel behaviour I State

Library Example: Detail of Use case borrow book

Use case diagram

User

LibrarySystem

borrow book

return book

search for book

Use case borrow bookBasic course of events:

1. User scans his library card2. User selects check out3. User scans the book4. System confirms loan

Page 12: 02291: System IntegrationUML Diagrams (II) I Behaviour Diagrams I Use-Case Diagram I How users interact with a system I Activity Diagram I Procedural and parallel behaviour I State

Implementation: Component Diagram

<<inter face>>LibraryInterface

scanLibraryCard()checkOutscanBook()checkIn...

LibraryInterface

LibrarySystem

Page 13: 02291: System IntegrationUML Diagrams (II) I Behaviour Diagrams I Use-Case Diagram I How users interact with a system I Activity Diagram I Procedural and parallel behaviour I State

Implementation: Class Diagram

Page 14: 02291: System IntegrationUML Diagrams (II) I Behaviour Diagrams I Use-Case Diagram I How users interact with a system I Activity Diagram I Procedural and parallel behaviour I State

Library SM

user okuser ok

can borrow?

...

...

book scannedUser scannedIdlecheckOut/return

[not cb] / return "book can't be borrowed"

scanBook(l)

[cb] / b.checkOut(); return "ok"

/ cb := bor.canBorrow()

[users->contains(l)]/return true

[not users->contains(l)] / return err-msg

scanLibraryCard (l)

Page 15: 02291: System IntegrationUML Diagrams (II) I Behaviour Diagrams I Use-Case Diagram I How users interact with a system I Activity Diagram I Procedural and parallel behaviour I State

Use Case success scenario realisationsd: borrow book success

scan librarycard(bor)

true

checkOut()

scan book(b)

canBorrow()

isOverdue()

false

loop

true

checkout(bor)

"Ok"

loop

User

Library bor:Borrower

[b in bor.books]

b1:Book b2:Book

Page 16: 02291: System IntegrationUML Diagrams (II) I Behaviour Diagrams I Use-Case Diagram I How users interact with a system I Activity Diagram I Procedural and parallel behaviour I State

Use case borrow book : User interactions

Use case borrow book :Basic course of events

1. User scans his library card2. User selects check out3. User scans the book4. System confirms loan

sd: borrow book success

scan librarycard(bor)

t rue

checkOut()

scan book(b)

canBorrow()

isOverdue()

false

loop

true

checkout(bor)

t rue

t rue

loop

UserLibrary bor:Borrower

[b in bor.books]

b1:Book b2:Book

Page 17: 02291: System IntegrationUML Diagrams (II) I Behaviour Diagrams I Use-Case Diagram I How users interact with a system I Activity Diagram I Procedural and parallel behaviour I State

Library SM

user okuser ok

can borrow?

...

...

book scannedUser scannedIdlecheckOut/return

[not cb] / return "book can't be borrowed"

scanBook(l)

[cb] / b.checkOut(); return "ok"

/ cb := bor.canBorrow()

[users->contains(l)]/return true

[not users->contains(l)] / return err-msg

scanLibraryCard (l)

sd: borrow book success

scan librarycard(bor)

true

checkOut()

scan book(b)

canBorrow()

isOverdue()

false

loop

true

checkout(bor)

"Ok"

loop

User

Library bor:Borrower

[b in bor.books]

b1:Book b2:Book