02291: System IntegrationIntroduction to UML
Hubert [email protected]
DTU ComputeTechnical University of Denmark
Spring 2019
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 Based on a metamodelI Not a development processI UML is an open standard and an ISO standard
I managed by the Object Management Group(www.omg.org)
I Web resourcesI http://www.uml.org
UML’s history
I 1980sI Objects became main streamI OO methods and graphical notations
I Grady Booch, Peter Coad, Ivar Jacobson, Jim Odell, JimRumbaugh, Sally Shlaer and Steve Mellor, RebeccaWirfs-Brock, . . .
I 1990sI Grady Booch, Ivar Jacobson and Jim Rumbaugh at
RationalI First version of the UML (UML 0.8)
I 1996I The Object Management Group (OMG)I Driven by tool vendors!
I Tool interoperability!I 1.x with 1.4 and 1.5 being widely used
I 2005I UML 2.0 ISO standard
Example of a class diagram
StartRoomSpecialRoom
Level
Player
Room
PersonalObject
nextLevel*
0..1
connectedTo*
*
1
1..* 1
*
0..1
*
*inventory
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}
Metamodel
I Abstract syntax of UML diagramsI Describes the concepts of UML elements
I e.g. class, association, . . .I concepts are mapped to notations
I e.g. the concept of a class is mapped to rectangle withsubcompartments
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 metamodel is important for model exchangeI XMI (XML Metadata Interchange)
The meaning of UML
I The abstract syntax / concepts: OK→ metamodel
I The meaning of the concepts: not well-definedI Meaning of class?I Execution of activity diagrams and state machines
I Semantic variation pointsI Left open in the standardI Tool vendors choose meaning
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
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
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
UML is not enough
I UML is a general purpose modelling languageI UML can be extended
I lightweight (UML profile)I heavy weight
→ Use the modelling language best suited for your purpose
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
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
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
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
Implementation: Component Diagram
<<inter face>>LibraryInterface
scanLibraryCard()checkOutscanBook()checkIn...
LibraryInterface
LibrarySystem
Library SM
user okuser ok
can borrow?
...
...
book scannedUser scannedIdlecheckOut
[not cb] / return "book can't be borrowed"
scanBook(l)
[cb] / b.checkOut(); return "ok"
/ cb := bor.canBorrow()
[users->contains(l)]
[not users->contains(l)] / return err-msg
scanLibraryCard (l)
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
Library SM
user okuser ok
can borrow?
...
...
book scannedUser scannedIdlecheckOut
[not cb] / return "book can't be borrowed"
scanBook(l)
[cb] / b.checkOut(); return "ok"
/ cb := bor.canBorrow()
[users->contains(l)]
[not users->contains(l)] / return err-msg
scanLibraryCard (l)
loop [foreach b' in bor->books]
Top Related