2. AAggeennddaa
Context of Work
Moving Executable Models to Android
A software architecture powered by PauWare
API
Conclusion & perspectives
Olivier Le Goaer @ MobiApps 2014
4. WWee eenntteerreedd tthhee mmooddeelliinngg eerraa
The power of software modeling
Mental effort that differs from that required for programming
A higher level of abstraction provides a better reasoning support
supposed to be more concise, more intelligible, more agile…
Model-driven engineering field (MDE)
Promotes the « model everywhere » vision
Models are considered first-class citizen during the software life-cycle
UML was just the tip of the iceberg; DSL are now at the forefront
Olivier Le Goaer @ MobiApps 2014
5. SSttaattiicc vveerrssuuss ddyynnaammiicc mmooddeellss
Classical MDE use static model
A model = a blueprint for a software viewpoint that one can refer
to do stuff
Testing, code generation, requirements elicitation, proofs, …
A recent MDE trend is about dynamic model
Extension that aims to breathe life into models
A dynamic model = an animated/actioned blueprint that plays a
leading role
Simulation and validation, rapid prototyping, ...
There is no code generation; The model is sufficient in itself.
Olivier Le Goaer @ MobiApps 2014
6. EExxeeccuuttaabbllee mmooddeellss
An execution engine is required
An interpreter manages each execution step of the model under
execution
Specific to each kind of models (petri nets, statecharts, workflows,
activity diagrams…)
Statechart is a prominent example of
executable model
Describes the behavior of something in terms of states and
transitions
Is a general-purpose modeling language
User navigation, Control flow... and generally speaking any object's life-cycle
Olivier Le Goaer @ MobiApps 2014
9. IIlllluussttrraattiioonn wwiitthh aa ttooyy mmoobbAApppp
Create a tiny mobApp « Energy Assistant »
An avatar gives (not too serious) advices to the end-user based
on both the battery level and the usage of his device
Statechart formalism to the rescue
This kind of mobApp can be easily modeled with a statechart
States will reflect the battery level
Events will be mapped to Android system events
Actions will be short notifications to the end-user (can be much more complex of
course)
Accessible even to non-specialists of Android platform
Requires a basic knowledge of how any mobile device operates
This allows us to imagine that a customer can entirely model its needs in that way
Olivier Le Goaer @ MobiApps 2014
10. SSttaatteecchhaarrtt mmooddeelliinngg gguuiiddeelliinnee
The control flow rises up to the model level
Much more easy to understand and to maintain that when buried
in code
Hence be careful that no control flow resides into the action code
A
B
[isOk] e1 / foo()
Olivier Le Goaer @ MobiApps 2014
public void foo() {
//do something
if (!isOk) {
//do something else
}
}
Interferes
with the
model !
11. EEnneerrggyy AAssssiissttaanntt''ss bbeehhaavviioorr
Olivier Le Goaer @ MobiApps 2014
4 states
Including a composite
2 pseudos-states
2 initials
0 final
7 transitions
No guards
7 Android-related
events
1 kind of action :
« alert »
12. AAnnddrrooiidd mmooddeelliinngg?? RReeaallllyy??
Classical code =
programming effort
"I am writing the code of my
Android app. My focus is at
the program-level."
Complex,
unmaintainable code
Nested if, switch
statements, ...
Flag variables and
« global » variables to
record what happened
previously...
Olivier Le Goaer @ MobiApps 2014
Model-oriented code
= modeling effort
"I am writing the code that
describes a statechart
model of my Android app.
My focus is at the model-level."
Clear separation of
concerns
Statechart description
Actions' implementation
Let an engine executes
directly the model
14. PPaauuWWaarree EExxeeccuuttiioonn EEnnggiinnee
PauWare engine (www.pauware.com)
Lightweight execution engine for statechart models
Implements the complete UML2 execution semantics specification
API written in Java (hence ported effortlessly to Android)
Engine that executes the model
loaded (« run-to-completion »)
Olivier Le Goaer @ MobiApps 2014
JJaavvaa
PPaauuWWaarree AAPPII
Code/xml that describes the
statechart model to be loaded
Consumes an
event for each
execution step
Free implementation of
the actions
(called by reflection from the engine)
15. AArrcchhiitteeccttuurree oovveerrvviieeww
Java or xmi or scxml
Olivier Le Goaer @ MobiApps 2014
SERVICE
BROADCAST
RECEIVER
AAnnddrrooiidd OOSS
ANDROID
CONNECTOR
e1/foo
e1
public void foo() {
//do something
}
public void bar() {
//do other thing
}
A statechart model
runs-to-completion
PauWare
Execution
Engine
starts invokes
19. CCoonncclluussiioonn
Executable models
There is no code generation, the model is directly executed on a
target platform through an engine (.i.e. an interpreter)
Android modeling rather than android
programming
Shift the efforts on modeling activities (for those who are not
allergic to modeling ;-)
Limited knowledge of the underlying platform is enough
Stateshart formalism and beyond
Widespread and well suited for aspects of apps (partly or entirely)
A lot of further modeling languages can be useful...
Olivier Le Goaer @ MobiApps 2014
20. PPeerrssppeeccttiivvee:: uuppddaattee mmaaddee eeaassyy
Ability to load a new model on-the-fly
A model is just a (meta)data taken as input of the engine
Actions' implementation have to stay unchanged
Challenge: the execution continuum between old and new model
Fresh (meta)data retrieval
Olivier Le Goaer @ MobiApps 2014
SERVICE
BROADCAST
RECEIVER
AAnnddrrooiidd OOSS
ANDROID
CONNECTOR
runs-to-completion
PauWare
Execution
Engine
ACTION_POWER_CONNECTED
void alert(String msg) {
Notification noti
= new Notification.Builder
...
}
starts invokes
Model
Server
Google
Cloud
Messaging Push Notification
Lifecycle : (design-time & run-time & maintenance)
Some students are very skilled for programming and have difficulties with modeling. It is very surprising
A basic principle is that
In that case, one must add another transition wich explicit the guard and the action
Notice that there is no final state. It is not mandatory
These are build-in android events
Nested states
Described by this sentence
Now imagine a very complex model: composite state, history state : power of statechart