36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the...
Transcript of 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the...
![Page 1: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/1.jpg)
36. Story Driven Modeling – A Practical Guide to Model Driven Software Development
Courtesy to Prof. Albert Zündorf, University of Kassel, Germany, Given in Dresden in 2005http://www.se.eecs.uni-kassel.de/typo3/index.php?albert
Tutorial
![Page 2: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/2.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 2
Content
1. Overview
2. The running example: Ludo
3. Use case description
4. Object oriented analysis with story boards
5. Test derivation
6. Derivation of design and implementation
7. Validation
![Page 3: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/3.jpg)
Fujaba Graph Rewriting Tool
http://www.fujaba.de/
http://www.fujaba.de/no_cache/publications.html
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 3
![Page 4: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/4.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 4
Overview
Steps:
Textual use case description
Story Boarding (OOA)(Test specification)
Class diagram derivation (OOD)
Behavior derivation (Coding)
Code generation
Validation (Testing)
Features:
Use Case Driven
Model Driven
Iterative
Test Driven Development
Story Driven Modeling:
![Page 5: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/5.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 5
36.2. The running example: Ludo
![Page 6: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/6.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 6
36.3. Use case diagrams (Rpt.)
Requirements elicitation as usual:
Use case diagrams for overview
![Page 7: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/7.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 7
Use case description (cont.)
Textual scenario descriptions:
focus on scenarios
several scenarios per use case
focus on one example situation at a time
use concrete names
Use case _ _ _ _ _ _, _ _ _ _ _ _ :
Start situation: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Invocation: _ _ _ _ _ _ _ _ _ _ _ _ _
Step 1: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Step 2: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Result situation: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
![Page 8: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/8.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 8
4. Object oriented analysis with story boards
SDM approach:
analyse the text scenarios
nouns become objects
verbs become method invocations or links
...
Start Situation: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Story-Driven Modeling (SDM)
![Page 9: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/9.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 9
36.4 Object oriented analysis with story boards
use case execution is modeled by one method invocation
drawn as collaboration message
multiple scenarios for one use case call the same method(but in different situations)
this method implements the use case
use case method mapping enables tracebility
step descriptions may become implementation comments
Actor step 1: _ _ _ _ _ _ _ _ _ _ _ _
1: _ _ _ _ _ _ _ _
![Page 10: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/10.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 10
Object oriented analysis with story boards
use case method mapping
uc1 <<uses>> uc2 method uc1() may call method uc2()
uc1 <<includes>> uc2 uc1() always calls uc2()
uc2 <<extends>> uc1 uc1() provides extension points / call backs. uc2() may subscribe for such a call back
![Page 11: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/11.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 11
Object oriented analysis with story boards
Outlining method behavior in concrete example situations:
Step 1: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<<create>> and <<destroy>> markers
:= attribute assignments
recurring objects without class namefirst time on stage with class name(change of perspective)
collaboration messages
alternatively sequence diagrams
tom
theDie
counter1
f1 f2 :Field
v == 3v := 2
counters
atat at
other :Counter
at
next
die
«destroy»
«destroy»
«destroy»«create»
1: go()
![Page 12: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/12.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 12
Object oriented analysis with story boards
Result situation:
models resulting object structure
used for testing
Result Situation: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tom
theDie
counter1
f4
v == 0
counters
atat
die
![Page 13: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/13.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 13
Derivation of Class Diagrams
Classes
Associations
Attribute declarations
Method declarations
Collect the types from the story boards:
![Page 14: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/14.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 14
Derivation of Class Diagrams (cont.)
Class diagram derivation is straight forward
Semi-automatic tool support by Fujaba
Intermediate story board step results in much better domain level class diagrams
code generation for class diagrams
story boards are appropriate for the analysis and discussion of behavior
story boards also useful during refinement and coding
story boards may serve as test specifications
story boards may drive the implementation
![Page 15: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/15.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 15
36.5. Test Derivation
Scenarios JUnit Tests
start situation setup code
invocation invocation
result situation code that checks object structure equivalence
![Page 16: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/16.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 16
Test Derivation (cont.)
Scenarios JUnit Tests, start situation setup code and fixture
Start Situation: Tom rolled a 3 and selects counter 1 for moving
theDie :Die
f2 :Field
v == 3
counters
at
next
die
f3 :Fieldnext
f4 :Field
next
class TestMoveUsual implements TestCase {private Player tom;private Die theDie;private Counter counter1;... void setUp () {
tom = new Player ();theDie = new Die ();
theDie.setV (3)
tom.setDie (theDie);
counter1 = new Counter ();tom.addToCounters (counter1);. . .
tom :Player
counter1 :Counter
f1 :Field
tom theDie
counter1
f2f1
f3f4
:TestMoveUsual
![Page 17: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/17.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 17
Test Derivation (cont.2)
Scenarios JUnit Tests, start situation setup code
Invocation: counter 1 is moved class TestMoveUsual implements TestCase {
. . .
void testMoveUsual () {
this.counter1.move();
. . .
counter1 1: move ()
![Page 18: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/18.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 18
Test Derivation (cont.3)
Scenarios JUnit Tests, start situation setup code
class TestMoveUsual implements TestCase { void testMoveUsual () {
this.counter1.move();
assertTrue (tom.getDie() == theDie);
assertTrue (theDie.getV() == 0);
assertTrue (counter1.getPlayer () == tom);
assertTrue (counter.getAt () == f4);
}
Result Situation: the die is counted down to zero and counter 1 reached field 4
tom
theDie
counter1
f4
v == 0
counters
atat
die
![Page 19: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/19.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 19
Test Derivation (cont.4)
more complex result situations work, too (see later)
start situation, invocation, result situation JUnit tests
steps may be exploited, too, cf. [SCESM05]
analysis scenarios tests
test driven software development
![Page 20: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/20.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 20
Derivation of the Implementation
Dobs + BeanShell + Coding
Tool Demo
or
combine story boards to rule diagrams [SCESM04]
assign execution semantics
code generation
![Page 21: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/21.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 21
Derivation of the Implementation (cont.)
this
pos
myPlayer
theDie 2
at
next
Main Memory Objects Rule Diagram / Program
![Page 22: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/22.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 22
Derivation of the Implementation (cont.2)
21
at
this
pos next
myPlayer
theDie
at
Main Memory Objects Rule Diagram / Program
![Page 23: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/23.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 23
Derivation of the Implementation (cont.3)
10
this
pos next
myPlayer
theDie
at
at
Main Memory Objects Rule Diagram / Program
![Page 24: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/24.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 24
Derivation of the Implementation (cont.4)
0
this
pos
at
Main Memory Objects Rule Diagram / Program
![Page 25: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/25.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 25
Derivation of the Implementation (cont.5)
0
pos
at
this
otherCounterotherCounter
otherPlayermyPlayer
Main Memory Objects Rule Diagram / Program
![Page 26: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/26.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 26
Derivation of the Implementation (cont.6)
class Counter { public void move () { Position pos; . . . while (sdmSuccess) {
try {sdmSuccess = false;pos = this.getAt ();JavaSDM.ensure (pos != null);next = pos.getNext ();JavaSDM.ensure (next != null);myPlayer = this.getOwner ();JavaSDM.ensure (myPlayer != null);theDie = myPlayer.getDie ();JavaSDM.ensure (theDie != null);JavaSDM.ensure (theDie.getV() > 0);sdmSuccess = true;this.setAt (null);this.setAt (next);theDie.setV(theDie.getV() - 1); }catch (SDMException e) {}
} // while
![Page 27: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/27.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 27
Derivation of the Implementation (cont.7)
thisthis
looser
lostCounter
noPosnoPos noPos
lhome
at
![Page 28: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/28.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 28
Derivation of the Implementation (cont.8)class Game { public void collectThrownCounters () { . . . Iterator looserIter = this.iteratorOfPlayers();while (!sdmSuccess && looserIter.hasNext()) {
try {sdmSuccess = false;looser = looserIter.next ();lhome = looser.getHome ();JavaSDM.ensure (lhome != null);countersIter = looser.iteratorOfCounters ();while (!sdmSuccess && countersIter.hasNext()) {
try {lostCounter = countersIter.next ();JavaSDM.ensure (lostCounter.getAt() == null);sdmSuccess = true;lostCounter.setAt (lhome);} catch (SDMException e) {}
} // while } catch (SDMException e) {}
} // while
![Page 29: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/29.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 29
Derivation of the Implementation (cont.9)
manual derivation of rule diagrams from stories
brain required
systematic guide lines provided e.g. in [SCESM04]
automatic code generation [GraGra]
![Page 30: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/30.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 30
Summary
Story Driven Modeling
model level analysis with story boards
model level tests
model level implementation with rule diagrams
code generation
model level testing / debugging
www.fujaba.de [email protected]
![Page 31: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/31.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 31
Addendum A: Story Pattern Elements:
v : Class
v
v
v : ClassVariables:
v : Class v : Class v : Class«create» «create»
v
v : Class v : Class«create»
v«create»
v : Classv : Class v : Classv : Class v : Classv v : Classv
Attributes: ...
attr <cmpOp> value
attr := value
Constrains:
{ <boolExpr> }
Links:assoc
ref
...
assoc[<key>]
«create» «create»
«create»
vv : Class
{first} {last}
«destroy»
«destroy»
«destroy» «destroy»
«destroy»
«destroy»
«destroy» 1: m () 2 [x>0]: m () 2.1 [while x>0]: m ()
![Page 32: 36. Story Driven Modeling – A Practical Guide to Model ... · Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on](https://reader030.fdocuments.us/reader030/viewer/2022040710/5e118d003ae9a54cfe6b42c8/html5/thumbnails/32.jpg)
Fujaba Tutorial Story Driven Modeling © 2005 Albert Zündorf, University of Kassel 32
References
[SCESM04] I. Diethelm, L. Geiger, A. Zündorf: Systematic Story Driven Modeling, a case study; Workshop on Scenarios and state machines: models, algorithms, and tools; ICSE 2004, Edinburgh, Scottland, May 24 – 28 (2004).
[SCESM05] Leif Geiger, Albert Zündorf: Story Driven Testing; in proc. 4th International Workshop on Scenarios and State Machines: Models, Algorithms and Tools (SCESM'05) ICSE 2005 Workshop
[GraGra] T.Fischer, J.Niere, L.Torunski, A.Zündorf: Story Diagrams: A new Graph Grammar Language based in the Unified Modeling Language; in Proc. of TAGT '98 - 6th International Workshop on Theory and Application of Graph Transformation. Technical Report tr-ri-98-201, University of Paderborn; (1999)