Android executable modeling: beyond android programming

download Android executable modeling: beyond android programming

If you can't read please download the document

Transcript of Android executable modeling: beyond android programming

  • 1. AAnnddrrooiidd EExxeeccuuttaabbllee MMooddeelliinngg::BBeeyyoonndd AAnnddrrooiidd PPrrooggrraammmmiinnggOlivier Le [email protected] # Session 1: Smart SystemsBarcelona, 2014

2. AAggeennddaa Context of Work Moving Executable Models to Android A software architecture powered by PauWareAPI Conclusion & perspectivesOlivier Le Goaer @ MobiApps 2014 3. CCoonntteexxtt ooff WWoorrkk 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 forefrontOlivier 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 referto 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 aleading 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 underexecution Specific to each kind of models (petri nets, statecharts, workflows,activity diagrams) Statechart is a prominent example ofexecutable model Describes the behavior of something in terms of states andtransitions Is a general-purpose modeling language User navigation, Control flow... and generally speaking any object's life-cycleOlivier Le Goaer @ MobiApps 2014 7. EExxeeccuuttaabbllee ssttaatteecchhaarrttss ffoorr rreeaall......From Statecharts: A visual formalism for complex systems by David HARELOlivier Le Goaer @ MobiApps 2014 8. MMoovviinngg EExxeeccuuttaabbllee MMooddeellss ttooAAnnddrrooiidd 9. IIlllluussttrraattiioonn wwiitthh aa ttooyy mmoobbAApppp Create a tiny mobApp Energy Assistant An avatar gives (not too serious) advices to the end-user basedon 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 ofcourse) 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 wayOlivier 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 buriedin code Hence be careful that no control flow resides into the action codeAB[isOk] e1 / foo()Olivier Le Goaer @ MobiApps 2014public void foo() {//do somethingif (!isOk) {//do something else}}Interfereswith themodel ! 11. EEnneerrggyy AAssssiissttaanntt''ss bbeehhaavviioorrOlivier Le Goaer @ MobiApps 2014 4 states Including a composite 2 pseudos-states 2 initials 0 final 7 transitions No guards 7 Android-relatedevents 1 kind of action : alert 12. AAnnddrrooiidd mmooddeelliinngg?? RReeaallllyy?? Classical code =programming effort "I am writing the code of myAndroid app. My focus is atthe program-level." Complex,unmaintainable code Nested if, switchstatements, ... Flag variables and global variables torecord what happenedpreviously...Olivier Le Goaer @ MobiApps 2014 Model-oriented code= modeling effort "I am writing the code thatdescribes a statechartmodel of my Android app.My focus is at the model-level." Clear separation ofconcerns Statechart description Actions' implementation Let an engine executesdirectly the model 13. A software AArrcchhiitteeccttuurree ppoowweerreedd bbyyPPaauuWWaarree AAPPII 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 modelloaded ( run-to-completion )Olivier Le Goaer @ MobiApps 2014JJaavvaaPPaauuWWaarree AAPPIICode/xml that describes thestatechart model to be loadedConsumes anevent for eachexecution stepFree implementation ofthe actions(called by reflection from the engine) 15. AArrcchhiitteeccttuurree oovveerrvviieewwJava or xmi or scxmlOlivier Le Goaer @ MobiApps 2014SERVICEBROADCASTRECEIVERAAnnddrrooiidd OOSSANDROIDCONNECTORe1/fooe1public void foo() {//do something}public void bar() {//do other thing}A statechart modelruns-to-completionPauWareExecutionEnginestarts invokes 16. AAnn eexxaammpplleeOlivier Le Goaer @ MobiApps 2014Active stateTriggeredtransition 17. EEnneerrggyy AAssssiissttaanntt''ss AArrcchhiitteeccttuurreeOlivier Le Goaer @ MobiApps 2014SERVICEBROADCASTRECEIVERAAnnddrrooiidd OOSSANDROIDCONNECTORPauWareExecutionEngineACTION_POWER_CONNECTEDvoid alert(String msg) {Notification noti= new Notification.Builder...}runs-to-completionstarts invokes 18. SSccrreeeennsshhoottssAssistant availablefrom the LauncherOlivier Le Goaer @ MobiApps 2014Assistant notificationPOWER_CONNECTED 19. CCoonncclluussiioonn Executable models There is no code generation, the model is directly executed on atarget platform through an engine (.i.e. an interpreter) Android modeling rather than androidprogramming Shift the efforts on modeling activities (for those who are notallergic 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 modelFresh (meta)data retrievalOlivier Le Goaer @ MobiApps 2014SERVICEBROADCASTRECEIVERAAnnddrrooiidd OOSSANDROIDCONNECTORruns-to-completionPauWareExecutionEngineACTION_POWER_CONNECTEDvoid alert(String msg) {Notification noti= new Notification.Builder...}starts invokesModelServerGoogleCloudMessaging Push Notification 21. QQuueessttiioonnss??