Complete Code Generation from UML State Machine

Van Cam Pham, Ansgar Radermacher, Sébastien Gérard, Shuai Li


An event-driven architecture is a useful way to design and implement complex systems. The UML State Machine and its visualizations are a powerful means to the modeling of the logical behavior of such an architecture. In Model Driven Engineering, executable code can be automatically generated from state machines. However, existing generation approaches and tools from UML State Machines are still limited to simple cases, especially when considering concurrency and pseudo states such as history, junction, and event types. This paper provides a pattern and tool for complete and efficient code generation approach from UML State Machine. It extends IF-ELSE-SWITCH constructions of programming languages with concurrency support. The code generated with our approach has been executed with a set of state-machine examples that are part of a test-suite described in the recent OMG standard Precise Semantics Of State Machine. The traced execution results comply with the standard and are a good hint that the execution is semantically correct. The generated code is also efficient: it supports multi-thread-based concurrency, and the (static and dynamic) efficiency of generated code is improved compared to considered approaches.


  1. Badreddin, O., Lethbridge, T. C., Forward, A., Elaasar, M., Aljamaan, H., and Garzon, M. A. (2014a). Enhanced code generation from uml composite state machines. In Model-Driven Engineering and Software Development (MODELSWARD), 2014 2nd International Conference on, pages 235-245. IEEE.
  2. Badreddin, O., Lethbridge, T. C., Forward, A., Elasaar, M., and Aljamaan, H. (2014b). Enhanced Code Generation from UML Composite State Machines. Modelsward 2014, pages 1-11.
  3. Balser, M., Bäumler, S., Knapp, A., Reif, W., and Thums, A. (2004). Interactive verification of uml state machines. In International Conference on Formal Engineering Methods, pages 434-448. Springer.
  4. Blech, J. O. and Glesner, S. (2005). Formal verification of java code generation from uml models. In . . . of the 3rd International Fujaba Days, pages 49-56.
  5. Booch, G., Rumbaugh, J., and Jacobson, I. (1998). The Unified Modeling Language User Guide , volume 3.
  6. Boost Library (2016a). Boost C++. [Online; accessed 04-July-2016].
  7. Boost Library (2016b). Meta State Machine. http:// 59 0 b1/libs/msm/doc/ HTML/index.html. [Online; accessed 04-July-2016].
  8. Boost Library (2016c). State Machine Benchmark. 61 0/libs/msm/doc/ HTML/ch03s04.html.
  9. Boost Library (2016d). The Boost Statechart Library. [Online; accessed 04-July-2016].
  10. Butenhof, D. R. (1997). Programming with POSIX threads. Addison-Wesley Professional.
  11. Charfi, A., Mraidha, C., and Boulet, P. (2012). An optimized compilation of uml state machines. In 2012 IEEE 15th International Symposium on Object/Component/Service-Oriented Real-Time Distributed Computing, pages 172-179.
  12. Domínguez, E., P érez, B., Rubio, A. L., and Zapata, M. A. (2012). A systematic review of code generation proposals from state machine specifications.
  13. Douglass, B. P. (1999). Real-time UML : developing efficient objects for embedded systems.
  14. Forward, A., Lethbridge, T. C., and Badreddin, O. (2010). Perceptions of software modeling: A survey of software practitioners. In in 5th Workshop from Code Centric to Model Centric: Evaluating the Effectiveness of MDD (C2M: EEMDD), 2010. Available: http://www. esi. es/modelplex/c2m/papers. php. Citeseer.
  15. Gérard, S., Dumoulin, C., Tessier, P., and Selic, B. (2010). 19 papyrus: A uml2 tool for domain-specific language modeling. In Model-Based Engineering of Embedded Real-Time Systems, pages 361-368. Springer.
  16. IBM (2016a). IBM Rhapshody and UML differences. uid=swg27040251. [Online; accessed 04-July-2016].
  17. IBM (2016b). Ibm Rhapsody. [Online; accessed 04-July2016].
  18. Jusiak, K. (2016). State Machine Benchmark. https:// [Online; accessed 20-Oct-2016].
  19. Katz, R. H. and Borriello, G. (2005). Contemporary logic design.
  20. Knapp, A. (2004). Semantics of UML State Machines.
  21. Lavender, R. G. and Schmidt, D. C. (1996). Active Object. Context, pages 1-12.
  22. Magic, N. (2016). Magic Draw. https:// [Online; accessed 14-Mar-2016].
  23. Mussbacher, G., Amyot, D., Breu, R., Bruel, J.-m., Cheng, B. H. C., Collet, P., Combemale, B., France, R. B., Heldal, R., Hill, J., Kienzle, J., and Schöttle, M. (2014). The Relevance of Model-Driven Engineering Thirty Years from Now. ACM/IEEE 17th International Conference on Model Driven Engineering Languages and Systems (MODELS), pages 183-200.
  24. Nethercote, N. and Seward, J. (2007). Valgrind: a framework for heavyweight dynamic binary instrumentation. In ACM Sigplan notices, volume 42, pages 89- 100. ACM.
  25. Niaz, I. A., Tanaka, J., and others (2004). Mapping UML statecharts to java code. In IASTED Conf. on Software Engineering, pages 111-116.
  26. OMG (2016). Precise Semantics of UML State Machines (PSSM) Revised Submission. [Revised Submission, ad/16-11-01].
  27. Papyrus (2016). Moka Model Execution. https://wiki. [Online; accessed 01-Nov-2016].
  28. Pilitowski, R. and Derezin˜ska, A. (2007). Code Generation and Execution Framework for UML 2.0 Classes and State Machines, pages 421-427. Springer Netherlands, Dordrecht.
  29. Quantum Leaps (2016). Quantum Modeling. http:// [Online; accessed 14- May-2016].
  30. Shalyto, A. and Shamgunov, N. (2006). State machine design pattern. Proc. of the 4th International Conference on.NET Technologies.
  31. SparxSysems (2016). Enterprise Architect. http:// [Online; accessed 14-Mar-2016].
  32. SparxSystems (2016). Enterprise Architect. http:// [Online; accessed 20-Nov-2016].
  33. Specification, O. M. G. A. and Bars, C. (2007). OMG Unified Modeling Language ( OMG UML ). Language, (November):1 - 212.
  34. Spinke, V. (2013). An object-oriented implementation of concurrent and hierarchical state machines. Information and Software Technology, 55(10):1726-1740.
  35. Valgrind (2016). Valgrind Massif. manual/ms-manual.html. [Online; accessed 20-Nov2016].
  36. Whittle, J., Hutchinson, J., and Rouncefield, M. (2014). Model-driven engineering practices in industry: Social, organizational and managerial factors that lead to success or failure. Science of Computer Programming, 89:144-161.
  37. Yasmine (2016). The classic farmroad example. http:// [Online; accessed 20-Nov-2016].

Paper Citation

in Harvard Style

Pham V., Radermacher A., Gérard S. and Li S. (2017). Complete Code Generation from UML State Machine . In Proceedings of the 5th International Conference on Model-Driven Engineering and Software Development - Volume 1: MODELSWARD, ISBN 978-989-758-210-3, pages 208-219. DOI: 10.5220/0006274502080219

in Bibtex Style

author={Van Cam Pham and Ansgar Radermacher and Sébastien Gérard and Shuai Li},
title={Complete Code Generation from UML State Machine},
booktitle={Proceedings of the 5th International Conference on Model-Driven Engineering and Software Development - Volume 1: MODELSWARD,},

in EndNote Style

JO - Proceedings of the 5th International Conference on Model-Driven Engineering and Software Development - Volume 1: MODELSWARD,
TI - Complete Code Generation from UML State Machine
SN - 978-989-758-210-3
AU - Pham V.
AU - Radermacher A.
AU - Gérard S.
AU - Li S.
PY - 2017
SP - 208
EP - 219
DO - 10.5220/0006274502080219