advanced support for executable statechart modelling

26
Advanced support for executable statechart modelling Tom Mens & Alexandre Decan So-ware Engineering Lab Department of Computer Science informatique.umons.ac.be/genlog

Upload: tom-mens

Post on 08-Jan-2017

184 views

Category:

Science


0 download

TRANSCRIPT

Page 1: Advanced support for executable statechart modelling

Advancedsupportfor executablestatechartmodelling

TomMens&AlexandreDecanSo-wareEngineeringLab

DepartmentofComputerScience

informatique.umons.ac.be/genlog

Page 2: Advanced support for executable statechart modelling

ResearchContextModel-drivenso-wareengineeringGoal

Increasequalityandreliabilityofso-waresystemsbeforeimplementa.onphasethroughuseofvisualdesignmodels

How?• Specifystructureandbehaviourofso-ware-intensivesystems•athighlevelofabstracJon•withoutconsideringtechnicaldetails

• Allowformalreasoningoverthesystem• Testandsimulatesystembehaviour• FacilitatesystemevoluJon• ExploredesignalternaJves• AutomatedcodegeneraJon

2TomMens–INFORTECHday—UMONS–21April2016

Page 3: Advanced support for executable statechart modelling

ResearchContextModel-drivenso-wareengineering

3TomMens–INFORTECHday—UMONS–21April2016

BottomUp TopDown

Activities:Formalverification,modelchecking,theoremproving,…Formalisms:temporallogics,automata,Petrinets,gametheory,…

Activities:Modelexecution,modelsimulation,automatedtesting,codegeneration,…

Modelinglanguages:UMLmodels,businessprocessmodels,…

Page 4: Advanced support for executable statechart modelling

ResearchContextExecutablemodelling

4TomMens–INFORTECHday—UMONS–21April2016

state of

the art

Code

Automation level

Abstraction level

code

only

code

centric

Code Code Code

Model Model Model Model

round-trip

engineering

model

centric

executable

models

visualise synchronise generate

Page 5: Advanced support for executable statechart modelling

FocusonstatechartmodelsFrequentlyusedinindustry!Well-suitedfordescribingevent-drivenbehaviourofconcurrent,real-Jmesystems

ResearchContextExecutablemodelling

5TomMens–INFORTECHday—UMONS–21April2016

Page 6: Advanced support for executable statechart modelling

TomMens–INFORTECHday—UMONS–21April2016

Executablestatechartmodelling

Elevatorexample

Page 7: Advanced support for executable statechart modelling

Executablestatechartmodelling

Prosandcons!

Commercialtoolsupportavailable• IBMStatemate,IBMRhapsody,MathWorksStateflow,YakinduStatechartTools

“StandardisaJon”throughUML!ManysemanJcvariaJonsNoopensourcesoluJonsLimitedsupportforadvanceddevelopment

techniques

7TomMens–INFORTECHday—UMONS–21April2016

Page 8: Advanced support for executable statechart modelling

Executablestatechartmodelling

Researchgoals

Providemoreadvancedsupportforstatecharts• DealingwithsemanJcvariaJon• AutomatedtesJngandtestgeneraJon• Designbycontract• Behaviour-drivendevelopment• FormalverificaJonandmodelchecking• ComposiJonmechanisms• DesignspaceexploraJon• DetecJngqualityproblems• Applyingmodelrefactoring• ModelevoluJon

8TomMens–INFORTECHday—UMONS–21April2016

Page 9: Advanced support for executable statechart modelling

TomMens–INFORTECHday—UMONS–21April2016

Executablestatechartmodelling

Sismic

• InteractiveStatechartModelInterpreterandChecker– PythonlibraryavailableonPythonPackageIndex(PyPI)– releasedunderopensourcelicenceLGPLv3– Sourcecode• github.com/AlexandreDecan/sismic

– Documentation• sismic.readthedocs.org

Page 10: Advanced support for executable statechart modelling

TomMens–INFORTECHday—UMONS–21April2016

Executablestatechartmodelling

Sismic

• Executingstatechartbehavioursimulator=Interpreter(my_statechart)simulator.execute_once()simulator.queue(Event(’floorSelected’,floor=4))simulator.execute_once()

• Definingandrunningastorystory=Story([Event('floorSelected',floor=1),Pause(10),Event('floorSelected',floor=4),Pause(10)])story.tell(simulator)print(simulator.time) #20print(simulator.context.get('current')) #4

Page 11: Advanced support for executable statechart modelling

TomMens–INFORTECHday—UMONS–21April2016

• Addpreciseanddynamicallyverifiablespecificationstoexecutablesoftwarecomponents(e.g.,methods,functions,classes)

• BasedonBertrandMeyer’s “DesignbyContract”

• Thecodeshouldrespect acontract,composedof– preconditions– postconditions– invariants

Executablestatechartmodelling

Contract-drivendevelopment

classDICTIONARY[ELEMENT]featureput(x:ELEMENT;key:STRING)isrequirecount<=capacitynotkey.emptyensurehas(x)item(key)=xcount=oldcount+1endinvariant0<=countcount<=capacityend

Page 12: Advanced support for executable statechart modelling

TomMens–INFORTECHday—UMONS–21April2016

Executablestatechartmodelling

Contract-drivendevelopment

contractElevatorSystempre:current=0pre:destination=0inv:current>=0inv:destination>=0

Exampleofstatechartcontract

Page 13: Advanced support for executable statechart modelling

TomMens–INFORTECHday—UMONS–21April2016

Executablestatechartmodelling

Contract-drivendevelopment

Exampleofstatechartcontractcontextmoving

pre:destination<>currentpost:current=destination@pre

contextnotMovingpre:destination=current

contextdoorsOpeninv:notoclIsInState(moving)

contextmovingUppre:current<destination

post:current>current@pre

Page 14: Advanced support for executable statechart modelling

TomMens–INFORTECHday—UMONS–21April2016

Executablestatechartmodelling

Contract-drivendevelopment

DetectingcontractviolationsInvariantError!Object:BasicState(doorsOpen)Assertion:notactive('moving’)Configuration:['doors','elevator','floorListener','doorsOpen','floorSelector','moving','movingUp']!Step:MacroStep@10(InternalEvent(doorsReady),[Transition(waitingForDoors,movingUp,doorsReady)],>['moving','movingUp'],<['waitingForDoors','notMoving'])!Evaluationcontext:-destination=4-current=2

Page 15: Advanced support for executable statechart modelling

TomMens–INFORTECHday—UMONS–21April2016

ExecutablestatechartmodellingTest-driven&behaviour-drivendevelopment

Page 16: Advanced support for executable statechart modelling

TomMens–INFORTECHday—UMONS–21April2016

• Includeacceptancetestandcustomertestpracticesintotest-drivendevelopment

• Encouragecollaborationbetweendevelopers,QA,andnon-technicalstakeholders(domainexperts,projectmanagers,users)

• Useadomain-specific(non-technical)languagetospecifyhowthecodeshouldbehave– Bydefiningfeaturespecificationsandscenarios– UsingGherkinlanguage

• Reducesthetechnicalgapbetweendevelopersandotherprojectstakeholders

Executablestatechartmodelling

Behaviour-DrivenDevelopment

Page 17: Advanced support for executable statechart modelling

TomMens–INFORTECHday—UMONS–21April2016

Example(takenfromdocs.behat.org/en/v2.5/guides/1.gherkin.html)

Executablestatechartmodelling

Behaviour-drivendevelopment

Feature:ServecoffeeInordertoearnmoneycustomersshouldbeabletobuycoffee!Scenario:BuylastcoffeeGiventhereis1coffeeleftinthemachineAndIhavedeposited1dollarWhenIpressthecoffeebuttonThenIshouldbeservedacoffee

Page 18: Advanced support for executable statechart modelling

TomMens–INFORTECHday—UMONS–21April2016

Feature:Elevatorsystem(continued)!…!Scenario:Doorscloseafter10secondsGivenIreproduce"Elevatormovesto4thfloor"WhenIwait10secondsThenstatedoorsOpenshouldnotbeactive!Scenario:Elevatormovestogroundafter30secsGivenIreproduce"Doorscloseafter10seconds"WhenIwait30secondsThenthevalueofcurrentshouldbe0

Executablestatechartmodelling

Behaviour-drivendevelopment

Example:FeaturespecificationforElevatorstatechart

Feature:Elevatorsystem!Scenario:ElevatorstartsongroundfloorWhenIexecutethestatechartThenthevalueofcurrentshouldbe0Andthevalueofdestinationshouldbe0AndstatedoorsOpenshouldbeactive!Scenario:Elevatormovesto4thfloorWhenIsendeventfloorSelectedwithfloor=4Thenthevalueofcurrentshouldbe4AndstatedoorsOpenshouldbeactive

Page 19: Advanced support for executable statechart modelling

TomMens–INFORTECHday—UMONS–21April2016

Executablestatechartmodelling

Behaviour-drivendevelopment

• SupportingBDDFeature:ElevatorSystem[...]!1featurepassed,0failed,0skipped4scenariospassed,0failed,0skipped13stepspassed,0failed,0skipped,0undefinedTook0m0.017s

Page 20: Advanced support for executable statechart modelling

TomMens–INFORTECHday—UMONS–21April2016

Executablestatechartmodelling

Behaviour-drivendevelopment

• SupportingBDD

Failingscenarios:Elevatormovestogrounda-er30secs

AsserJonFailed:Variablecurrentequals4!=00featurespassed,1failed,0skipped 3scenariospassed,1failed,0skipped 12stepspassed,1failed,0skipped,0undefined

Took0m0.014s

Page 21: Advanced support for executable statechart modelling

TomMens–INFORTECHday—UMONS–21April2016

Executablestatechartmodelling

Sismic

• CoverageanalysisStatecoverage:92.86%Enteredstates:root(4)|elevator(4)|moving(4)|movingUp(12)|movingDown(4)|notMoving(8)|standing(9)|waitingForDoors(4)|doors(4)|doorsOpen(8)|doorsClosed(6)|floorSelector(4)floorListener(4)|Remainingstates:halted!Transitioncoverage:73.33%Processedtransitions:movingUp[None]->movingUp(9)|moving[None]->notMoving(4)|standing[None]->waitingForDoors(4)|...

Page 22: Advanced support for executable statechart modelling

TomMens–INFORTECHday—UMONS–21April2016

Executablestatechartmodelling

Sismic• Definingpropertiesoverstatecharts

– IfelevatordoesnotreceivefloorSelectedeventduring30seconds,groundfloorshouldbereached5secondsafter

– Canbecheckeddynamicallybymeansofruntimemonitoring

Page 23: Advanced support for executable statechart modelling

TomMens–INFORTECHday—UMONS–21April2016

ExecutablestatechartmodellingFuturework

• Compositionandcommunicationmechanisms

Page 24: Advanced support for executable statechart modelling

TomMens–INFORTECHday—UMONS–21April2016

ExecutablestatechartmodellingFuturework

• Automateddetectionofcontracts,basedon• dynamicanalysisofstatechartexecutions• staticsymbolicanalysisofactionsandguards

• Automatedtestgeneration• Basedoncontractspecifications• Basedonmutationtestingorconcolictesting

• Formalverificationandmodelchecking• Basedontemporallogicproperties• Expressedindomain-specificlanguage(e.g.Dwyerspecificationpatterns)

Page 25: Advanced support for executable statechart modelling

TomMens–INFORTECHday—UMONS–21April2016

ExecutablestatechartmodellingFuturework

• Supportforqualityanalysis• Detectionofmodelsmells

• Supportforqualityimprovement• Automated(behaviourpreserving)modelrefactoring

Page 26: Advanced support for executable statechart modelling

TomMens–INFORTECHday—UMONS–21April2016

ExecutablestatechartmodellingFuturework

• Softwareproductfamilydesignandvariabilityanalysis

• Example:featuremodel ofanelevatorcontrolsystemproductline