Model-based Software Engineering (02341)...In UML, there are different concepts and diagrams that...
Transcript of Model-based Software Engineering (02341)...In UML, there are different concepts and diagrams that...
Model-based Software Engineering
(02341, spring 2016)
Ekkart Kindler
Status and Recapitulation:
How far did we come?
Ekkart Kindler
3 MBSE (02341 f16), L09
Vision
Place Transition
1 source
1 target
Arc
*
PetriNet
Token
*
Node
Object
Analysis
Design
Implementation
Coding
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: APetriNetEditorIn15Minutes.diagr
Bundle-Version: 1.0.0.qualifier
Bundle-ClassPath: .
Bundle-Activator: PetriNets.diagram.part.PetriNetDiagr
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: PetriNets.diagram.edit.parts,
PetriNets.diagram.part,
PetriNets.diagram.providers
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.core.expressions,
org.eclipse.jface,
org.eclipse.ui.ide,
org.eclipse.ui.views,
org.eclipse.ui.navigator,
org.eclipse.ui.navigator.resources,
org.eclipse.emf.ecore,
org.eclipse.emf.ecore.xmi,
org.eclipse.emf.edit.ui,
org.eclipse.gmf.runtime.emf.core,
org.eclipse.gmf.runtime.emf.commands.core,
org.eclipse.gmf.runtime.emf.ui.properties,
org.eclipse.gmf.runtime.diagram.ui,
org.eclipse.gmf.runtime.diagram.ui.properties,
org.eclipse.gmf.runtime.diagram.ui.providers,
org.eclipse.gmf.runtime.diagram.ui.providers.ide,
org.eclipse.gmf.runtime.diagram.ui.render,
org.eclipse.gmf.runtime.diagram.ui.resources.ed
org.eclipse.gmf.runtime.diagram.ui.resources.e
APetriNetEditorIn15Minutes;visibility:=reexpor
package PetriNets.impl;
public class PetriNetImpl extends EObjectImpl implements PetriNet {
protected EList<PetriNets.Object> object;
protected PetriNetImpl() {
super();
}
protected EClass eStaticClass() {
return PetriNetsPackage.Literals.PETRI_NET;
}
public EList<PetriNets.Object> getObject() {
if (object == null) {
object = new EObjectContainmentEList<PetriNets.Object>(Petri
}
return object;
}
public NotificationChain eInverseRemove(InternalEObject otherEnd, int
switch (featureID) {
case PetriNetsPackage.PETRI_NET__OBJECT:
return ((InternalEList<?>)getObject()).basicRemove(otherEn
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case PetriNetsPackage.PETRI_NET__OBJECT:
return getObject();
}
return super.eGet(featureID, resolve, coreType);
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: APetriNetEditorIn15Minutes.diagr
Bundle-Version: 1.0.0.qualifier
Bundle-ClassPath: .
Bundle-Activator: PetriNets.diagram.part.PetriNetDiagr
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: PetriNets.diagram.edit.parts,
PetriNets.diagram.part,
PetriNets.diagram.providers
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.core.expressions,
org.eclipse.jface,
org.eclipse.ui.ide,
org.eclipse.ui.views,
org.eclipse.ui.navigator,
org.eclipse.ui.navigator.resources,
org.eclipse.emf.ecore,
org.eclipse.emf.ecore.xmi,
org.eclipse.emf.edit.ui,
org.eclipse.gmf.runtime.emf.core,
org.eclipse.gmf.runtime.emf.commands.core,
org.eclipse.gmf.runtime.emf.ui.properties,
org.eclipse.gmf.runtime.diagram.ui,
org.eclipse.gmf.runtime.diagram.ui.properties,
org.eclipse.gmf.runtime.diagram.ui.providers,
org.eclipse.gmf.runtime.diagram.ui.providers.ide,
org.eclipse.gmf.runtime.diagram.ui.render,
org.eclipse.gmf.runtime.diagram.ui.resources.ed
org.eclipse.gmf.runtime.diagram.ui.resources.e
APetriNetEditorIn15Minutes;visibility:=reexpor
package PetriNets.impl;
public class PetriNetImpl extends EObjectImpl implements PetriNet {
protected EList<PetriNets.Object> object;
protected PetriNetImpl() {
super();
}
protected EClass eStaticClass() {
return PetriNetsPackage.Literals.PETRI_NET;
}
public EList<PetriNets.Object> getObject() {
if (object == null) {
object = new EObjectContainmentEList<PetriNets.Object>(Petri
}
return object;
}
public NotificationChain eInverseRemove(InternalEObject otherEnd, int
switch (featureID) {
case PetriNetsPackage.PETRI_NET__OBJECT:
return ((InternalEList<?>)getObject()).basicRemove(otherEn
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case PetriNetsPackage.PETRI_NET__OBJECT:
return getObject();
}
return super.eGet(featureID, resolve, coreType);
Ekkart Kindler
4 MBSE (02341 f16), L09
Programming vs. SE
Ekkart Kindler
5 MBSE (02341 f16), L09
Vision
Place Transition
1 source
1 target
Arc
*
PetriNet
Token
*
Node
Object
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: APetriNetEditorIn15Minutes.diagr
Bundle-Version: 1.0.0.qualifier
Bundle-ClassPath: .
Bundle-Activator: PetriNets.diagram.part.PetriNetDiagr
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: PetriNets.diagram.edit.parts,
PetriNets.diagram.part,
PetriNets.diagram.providers
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.core.expressions,
org.eclipse.jface,
org.eclipse.ui.ide,
org.eclipse.ui.views,
org.eclipse.ui.navigator,
org.eclipse.ui.navigator.resources,
org.eclipse.emf.ecore,
org.eclipse.emf.ecore.xmi,
org.eclipse.emf.edit.ui,
org.eclipse.gmf.runtime.emf.core,
org.eclipse.gmf.runtime.emf.commands.core,
org.eclipse.gmf.runtime.emf.ui.properties,
org.eclipse.gmf.runtime.diagram.ui,
org.eclipse.gmf.runtime.diagram.ui.properties,
org.eclipse.gmf.runtime.diagram.ui.providers,
org.eclipse.gmf.runtime.diagram.ui.providers.ide,
org.eclipse.gmf.runtime.diagram.ui.render,
org.eclipse.gmf.runtime.diagram.ui.resources.ed
org.eclipse.gmf.runtime.diagram.ui.resources.e
APetriNetEditorIn15Minutes;visibility:=reexpor
package PetriNets.impl;
public class PetriNetImpl extends EObjectImpl implements PetriNet {
protected EList<PetriNets.Object> object;
protected PetriNetImpl() {
super();
}
protected EClass eStaticClass() {
return PetriNetsPackage.Literals.PETRI_NET;
}
public EList<PetriNets.Object> getObject() {
if (object == null) {
object = new EObjectContainmentEList<PetriNets.Object>(Petri
}
return object;
}
public NotificationChain eInverseRemove(InternalEObject otherEnd, int
switch (featureID) {
case PetriNetsPackage.PETRI_NET__OBJECT:
return ((InternalEList<?>)getObject()).basicRemove(otherEn
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case PetriNetsPackage.PETRI_NET__OBJECT:
return getObject();
}
return super.eGet(featureID, resolve, coreType);
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: APetriNetEditorIn15Minutes.diagr
Bundle-Version: 1.0.0.qualifier
Bundle-ClassPath: .
Bundle-Activator: PetriNets.diagram.part.PetriNetDiagr
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: PetriNets.diagram.edit.parts,
PetriNets.diagram.part,
PetriNets.diagram.providers
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.core.expressions,
org.eclipse.jface,
org.eclipse.ui.ide,
org.eclipse.ui.views,
org.eclipse.ui.navigator,
org.eclipse.ui.navigator.resources,
org.eclipse.emf.ecore,
org.eclipse.emf.ecore.xmi,
org.eclipse.emf.edit.ui,
org.eclipse.gmf.runtime.emf.core,
org.eclipse.gmf.runtime.emf.commands.core,
org.eclipse.gmf.runtime.emf.ui.properties,
org.eclipse.gmf.runtime.diagram.ui,
org.eclipse.gmf.runtime.diagram.ui.properties,
org.eclipse.gmf.runtime.diagram.ui.providers,
org.eclipse.gmf.runtime.diagram.ui.providers.ide,
org.eclipse.gmf.runtime.diagram.ui.render,
org.eclipse.gmf.runtime.diagram.ui.resources.ed
org.eclipse.gmf.runtime.diagram.ui.resources.e
APetriNetEditorIn15Minutes;visibility:=reexpor
package PetriNets.impl;
public class PetriNetImpl extends EObjectImpl implements PetriNet {
protected EList<PetriNets.Object> object;
protected PetriNetImpl() {
super();
}
protected EClass eStaticClass() {
return PetriNetsPackage.Literals.PETRI_NET;
}
public EList<PetriNets.Object> getObject() {
if (object == null) {
object = new EObjectContainmentEList<PetriNets.Object>(Petri
}
return object;
}
public NotificationChain eInverseRemove(InternalEObject otherEnd, int
switch (featureID) {
case PetriNetsPackage.PETRI_NET__OBJECT:
return ((InternalEList<?>)getObject()).basicRemove(otherEn
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case PetriNetsPackage.PETRI_NET__OBJECT:
return getObject();
}
return super.eGet(featureID, resolve, coreType);
Domain model (or model close to
domain model L10) from which some
code can be generated
Some code needs to be implemented
manually
Ekkart Kindler How conside are models
With class diagrams (EMF/Ecore diagrams), some
subtle aspects of some domains cannot be
appropriately modelled
Additional constraints (OCL or programmed in Java)
allow us to express these subtle aspects (more or
less adequately)
6 MBSE (02341 f16), L09
Ekkart Kindler Automatical code generation
structural parts of the software (API)
infrastructure (objects are notifiers) for saving and
loading object structures to files (in a default format
defined by the model: XMI)
default tree editors for editing object structures
factories for creating objects
...
With additional models for graphics
Fully functioning graphical editor
7 MBSE (02341 f16), L09
Ekkart Kindler Framework
Existing infrastructure
adapters, observer, notifications,
command framework, undo and redo mechanism,
command framework
MVC, many patterns behind the scene (we just
scratched the surface yet)
8 MBSE (02341 f16), L09
Ekkart Kindler Manually programming
Some specific graphics for ePNK programmed
manually YAWL graphics
Some technical classes (factory for specific
graphics) needed to be programmed manually
Some constraints programmed manually
Code for real functionality (editor is ”standard-
functionality”)
YAWL select actions
firing YAWL transition
9 MBSE (02341 f16), L09
Ekkart Kindler MBSE
The goal is not to get rid of programming as such;
but, to do things an the adequate level of abstraction
and in a clear and consise way
For some things, programming is an adequate and
consise way to do things (classical algorithms,
graphical appearance)
For other things, programming is not adequate and
just used for technical reasons: We want to get rid of
technical artifacts
10 MBSE (02341 f16), L09
Ekkart Kindler MBSE: Topics
How to model behaviour (so that code can be
generated)
What is behind the scenes:
Meta-modelling and meta-meta-modelling ( MOF)
Domain specific languages (DSL): Methodology
Code generation technologies
Model-transformation
Infrastructure (EMF and Eclipse behind the scenes)
11 MBSE (02341 f16), L09
Modelling Behaviour
Ekkart Kindler Overview
UML diagrams from modelling behaviour: overview
xUML (Executable UML): short overview
Other notations
Story Patterns: by example
The Event Coordination Notation (ECNO): by example
13 MBSE (02341 f16), L09
Ekkart Kindler
14 MBSE (02341 f16), L09
1. Behaviour in UML
In UML, there are different concepts and diagrams that
concern behaviour modelling
Use case diagrams
Activity diagrams
Interaction diagrams Sequence diagrams
Communication diagrams
State machine diagrams (State Charts)
Methods of classes (MOF: Operation) (in combination with OCL, the input/output relation of a method can be specified)
Ekkart Kindler
15 MBSE (02341 f16), L09
Activity diagrams
From: OMG Unified Modeling Language (OMG UML), Superstructure, V2.1.2,
November 2007, p. 331
Ekkart Kindler
16 MBSE (02341 f16), L09
turn key
“Sequence Diagram”
rain
sensor
ignition
switch wiper wiper
control
on
rain
on
off
Ekkart Kindler
17 MBSE (02341 f16), L09
”Communication Diagram”
ignition
switch
rain
sensor
wiper
wiper
control
1: on 2: off
3: rain
4: on
Ekkart Kindler
18 MBSE (02341 f16), L09
Sequence diagram (details)
o:Order item 1 item 2 product 1 product 2 :Customer
getPrice() getPrice()
getPrice()
amount()
sum1
getPrice() getPrice()
amount()
sum2
getCustomerDiscount()
discount
Lifeline
Message
Events Events
total
Ekkart Kindler
19 MBSE (02341 f16), L09
Sequence diagram (details)
o:Order item 1 item 2 product 1 product 2 :Customer
getPrice() getPrice()
getPrice()
amount()
sum1
getPrice() getPrice()
amount()
sum2
getCustomerDiscount()
discount
Call (synchronous)
return
Self-
call
total Activation
Ekkart Kindler
20 MBSE (02341 f16), L09
“State machines”
wiper
control
engine
off
wiper
off
rd.rain/w.on rd.dry/w.off
i
rd
w
Message
wiper
on
on
Initial state
off
rain on
off
Ekkart Kindler
21 MBSE (02341 f16), L09
Use of state machines
ignition
switch
rain
sensor
wiper
wiper
control
wiper
One automaton for each component
(plus structure) defines the complete
behaviour of our “wiper system”.
Ekkart Kindler
22 MBSE (02341 f16), L09
“State machines”
wiper
control
engine
off
wiper
off
i.on/w.off
i.off/w.off
rd.ra
in/w
.on
rd.d
ry/w
.off
i
rd
w
wiper
on
Complex
state
Ekkart Kindler
23 MBSE (02341 f16), L09
Behaviour in UML
Use case diagrams
Activity diagrams
Interaction diagrams
Sequence diagrams
Communication diagrams
State machine diagrams (State Charts)
Methods of classes (in combination with OCL, the input/output relation
of a method can be specified)
Ekkart Kindler Behaviour in UML
In general, UML behaviour models are used to
analyse, design, and document a system
It is hard to generate code from that automatically.
24 MBSE (02341 f16), L09
Ekkart Kindler 2. xUML
Restricted versions of UML
”Domain diagram” (package diagram)
Class diagrams for each ”domains”
Use Case diagrams
Sequence diagrams
State machines (signals triggering transitions)
Signals
UML Action Language (ASL) for defining
actions/operations on an abstract level and
independent from a programming language
25 MBSE (02341 f16), L09
Ekkart Kindler
26 MBSE (02341 f16), L09
2. Other behaviour models
Just to give a rough idea of the many concepts and
notations out there
Story Pattern (”Programming in Pictures”)
ECNO (just one idea)
Petri nets
Workflow languages (e.g. YAWL, BPMN)
BPEL, WSDL
Ekkart Kindler 3. Other notations
3.1 Story diagrams
27 MBSE (02341 f16), L09
Ekkart Kindler
28 MBSE (02341 f16), L09
Example: Material Flow System
Robot
Track Shuttle
Simple Gate
Good at occupied
1 0..1 0..1 0..1
pred
succ
Ekkart Kindler
29 MBSE (02341 f16), L09
An Instance
t1:Simple s:Shuttle
pred
occ
t2:Simple
succ
at
:Simple
pred
succ
pred
:Simple
succ
Ekkart Kindler
30 MBSE (02341 f16), L09
Behaviour
t1:Simple s:Shuttle
pred
occ
t2:Simple
succ
at
at
occ
:Simple
pred
succ
pred
:Simple
succ
before
after
Ekkart Kindler
31 MBSE (02341 f16), L09
Story Pattern
t1:Simple s:Shuttle
pred
occ
t2:Simple
succ
at
at
occ
<<delete>>
s:Shuttle occ at
Ekkart Kindler 3.2. Event Coordination Notation
Motivation
Given some object oriented software with
(or without) explicit domain model
Model behaviour on top of it – and make these models
executable
Model behaviour on a high level of abstraction
(domain level)
Integrate behaviour models with structural models
Integrate different structural models (even from different
technologies and without underlying models)
32 MBSE (02341 f16), L09
Ekkart Kindler
33 MBSE (02341 f16), L09
5.1 Example
Vending machine
Slot
Panel
Control
Coffee
Brewer
Output
*
*
*
*
*
*
Safe
Coin
Tea
1
Ekkart Kindler
34 MBSE (02341 f16), L09
Instance: object diagram
: Slot
:Panel
:Control
:Coffee
:Output
: Safe
:Coin
:Tea
:Coffee
:Coin
:Coin
Ekkart Kindler
35 MBSE (02341 f16), L09
Coordination Diagram
Slot
insert
return_
pass
reset
Panel GUI
coffee GUI
tea GUI
cancel GUI
Coffee
Output GUI
cup_in GUI
cup_out GUI
*
cup_in: 1
coffee: 1
tea: 1
reset: ALL
coffee: 1
tea: 1
cancel: ALL
reset: ALL
pass: 1
pass: 1
*
*
*
*
insert: 1
*
return_: ALL
pass: 1
Safe
pass
GUI Coin
insert GUI
pass
return_
Tea
Brewer
coffee
tea
reset
cup_in
1
Control
coffee
tea
cancel
pass
reset
Ekkart Kindler
36 MBSE (02341 f16), L09
... + Event declaration
Slot
insert
return_
pass
reset
Panel GUI
coffee GUI
tea GUI
cancel GUI
Control
coffee
tea
cancel
pass
reset Coffee
Output GUI
cup_in GUI
cup_out GUI
*
cup_in: 1
coffee: 1
tea: 1
reset: ALL
coffee: 1
tea: 1
cancel: ALL
reset: ALL
pass: 1
pass: 1
*
*
*
*
insert: 1
*
return_: ALL
pass: 1
Safe
pass
GUI Coin
insert GUI
pass
return_
Tea
insert(Coin coin, Slot slot) coffee() pass(Coin coin, Slot slot) tea() return(Slot slot) cancel() reset_() cup_in() cup_out()
Brewer
coffee
tea
reset
cup_in
1
Ekkart Kindler
37 MBSE (02341 f16), L09
Interactions
: Slot
:Panel
:Control
:Coffee
:Output
: Safe
:Coin
:Tea
:Coffee
:Coin
:Coin
coffee
coffee
coffee
pass pass pass
pass
coffee: 1
pass: 1
pass: 1
coffee: 1
coffee: 1
pass: 1
Ekkart Kindler
38 MBSE (02341 f16), L09
Interactions
: Slot
:Panel
:Control
:Coffee
:Output
: Safe
:Coin
:Tea
:Coffee
:Coin
:Coin
coffee
coffee
coffee
pass pass pass
pass
coffee: 1
pass: 1
pass: 1 coffee: 1
pass: 1
Ekkart Kindler
39 MBSE (02341 f16), L09
Another Interaction
: Slot
:Panel
:Control
:Coffee
:Output
: Safe
:Coin
:Tea
:Coffee
:Coin
:Coin
cancel reset
reset
reset reset
return
return
cancel
reset return
reset: ALL cancel: ALL
reset: ALL
reset: ALL reset: ALL
return: ALL
return: ALL
Ekkart Kindler
40 MBSE (02341 f16), L09
Local behaviour: Coffee
Ekkart Kindler
41 MBSE (02341 f16), L09
Local behaviour: Coin
Ekkart Kindler
42 MBSE (02341 f16), L09
Local behaviour: Control
reset
cancel
coffee
pass
Ekkart Kindler
43 MBSE (02341 f16), L09
Local behaviour: Slot
reset
return
Ekkart Kindler
44 MBSE (02341 f16), L09
Interactions
: Slot
:Panel
:Control
:Coffee
:Output
: Safe
:Coin
:Tea
:Coffee
:Coin
:Coin
cancel reset
reset
reset reset
return
return
cancel
reset return
reset: ALL cancel: ALL
reset: ALL
reset: ALL reset: ALL
return: ALL
return: ALL
Ekkart Kindler 5.2 ECNO: Basic Concepts
ElementTypes (Classes)
EventTypes with
parameters
Global Behaviour: Coordination annotations for references
Event type
Quantification (1 or ALL)
Local behaviour: ECNO nets
Event binding (with parameter assignment)
Condition
Action
45 MBSE (02341 f16), L09
insert(Coin coin, Slot slot)
Control
coffee
tea
cancel
pass
reset
Brewer
coffee tea
reset
cup_in
coffee: 1
tea: 1
reset: ALL
Ekkart Kindler ECNO: Basic Concepts
ElementTypes (Classes)
EventTypes with
parameters
Global Behaviour: Coordination annotations for references
Event type
Quantification (1 or ALL)
Local behaviour: Or something else
Event binding (with parameter assignment)
Condition
Action
46 MBSE (02341 f16), L09
Ekkart Kindler Another example: Petri nets
47 MBSE (02341 f16), L09
fire Transition t:
for ALL incoming Arcs a:
for ONE source Place p of Arc a:
find a token and remove it
for ALL outgoing arcs a:
for ONE target Place p of Arc a:
add a new Token
Transition t enabled:
for ALL incoming Arcs a:
for ONE source Place p of Arc a:
find a token
t
remove add
Ekkart Kindler Petri net: Class Diagram
48 MBSE (02341 f16), L09
Ekkart Kindler ECNO Semantics of PN
49 MBSE (02341 f16), L09
Ekkart Kindler
50 MBSE (02341 f16), L09
t1
t2 t3
t4
Ekkart Kindler Conclusion
There are many ways to model behaviour
You need to choose the adequate way
There are differnt ways for modelling behaviour so
that the software can be generated from it or that
models are exectued ”enacted” directly: But, this is
not ”mainstream” yet.
51 MBSE (02341 f16), L09