Reuse and Customization for Code Generators: Synergy by Transformations and Templates

  • Robert EikermannEmail author
  • Katrin Hölldobler
  • Alexander Roth
  • Bernhard Rumpe
Conference paper
Part of the Communications in Computer and Information Science book series (CCIS, volume 991)


Engineering languages for model-driven development (MDD) highly rely on code generators that systematically and efficiently generate source code from abstract models. Although code generation is an essential technique, there is still a lot of ad hoc mechanisms in use that prevent an efficient and reliable use and especially reuse of code generators.

The first part of the paper focuses on general mechanisms necessary to really allow reuse of flexible code generators. Based on these general considerations, we present a code generator infrastructure, that allows to easily develop a generator, but especially allows to adapt existing generators to different technology stacks and thus widely supports reusability, customizability, and flexibility.

In the second part of the paper, we present an integrated template- and transformation-based code generation approach. It enables efficient code generation of object-oriented code and retains the benefits of both approaches. Even more, its synergetic use improves usability beyond using just a single approach. Internally, an intermediate representation (IR) and a separation of the code generation process into three main steps is used. First, the input model is processed and transformed to the IR. Second, elements in the IR are manipulated by source and target language independent transformations. Target language specific implementations are added by templates, which are attached to IR elements. Third, the resulting IR is used by a template engine to generate code with a predefined set of default templates for a particular target language. The overall goal of this paper is to show how to address necessary code generator considerations to effectively and efficiently use engineering languages in MDD.


Code generation Model-to-model transformation Code generator development 


  1. 1.
    Baar, T., Whittle, J.: On the usage of concrete syntax in model transformation rules. In: Virbitskaite, I., Voronkov, A. (eds.) PSI 2006. LNCS, vol. 4378, pp. 84–97. Springer, Heidelberg (2007). Scholar
  2. 2.
    Balogh, A., Varró, D.: Advanced model transformation language constructs in the VIATRA2 framework. In: ACM Symposium on Applied Computing. ACM (2006)Google Scholar
  3. 3.
    Brunelière, H., Cabot, J., Dupé, G., Madiot, F.: MoDisco: a model driven reverse engineering framework. Inf. Softw. Technol. 56(8), 1012–1032 (2014)CrossRefGoogle Scholar
  4. 4.
    Chared, Z., Tyszberowicz, S.S.: Projective template-based code generation. In: CAiSE 2013 Forum at the 25th International Conference on Advanced Information Systems Engineering, vol. 998. (2013)Google Scholar
  5. 5.
  6. 6.
    Czarnecki, K., Eisenecker, U.W.: Generative Programming: Methods, Tools, and Applications. Addison-Wesley, Boston (2000)Google Scholar
  7. 7.
    Czarnecki, K., Helsen, S.: Classification of model transformation approaches. In: 2nd OOPSLA 2003 Workshop on Generative Techniques in the Context of MDA (2003)Google Scholar
  8. 8.
    Czarnecki, K., Helsen, S.: Feature-based survey of model transformation approaches. IBM Syst. J. 45(3), 621–645 (2006)CrossRefGoogle Scholar
  9. 9.
    Di Ruscio, D., Eramo, R., Pierantonio, A.: Model transformations. In: Bernardo, M., Cortellessa, V., Pierantonio, A. (eds.) SFM 2012. LNCS, vol. 7320, pp. 91–136. Springer, Heidelberg (2012). Scholar
  10. 10.
    El Beggar, O., Bousetta, B., Gadi, T.: Automatic code generation by model transformation from sequence diagram of system’s internal behavior. Int. J. Comput. Inf. Technol. 1(02), 129–146 (2012)Google Scholar
  11. 11.
    Eliens, A.: Principles of Object-Oriented Software Development. Addison-Wesley Longman Publishing Co. Inc., Boston (1994)zbMATHGoogle Scholar
  12. 12.
    Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley Professional, Boston (1995)zbMATHGoogle Scholar
  13. 13.
    Geiger, L., Schneider, C., Reckord, C.: Template- and modelbased code generation for MDA-tools. Technical report (2005)Google Scholar
  14. 14.
    Génova, G., Del Castillo, C.R., Llorens, J.: Mapping UML associations into Java code. J. Object Technol. 2(5), 135–162 (2003)CrossRefGoogle Scholar
  15. 15.
    Gessenharter, D.: Implementing UML associations in Java: a slim code pattern for a complex modeling concept. In: Workshop on Relationships and Associations in Object-Oriented Languages (RAOOL 2009). ACM (2009)Google Scholar
  16. 16.
    Girschick, M.: Integrating template-based code generation into graphical model transformation. In: Modellierung 2008, Berlin (2008)Google Scholar
  17. 17.
    Greifenberg, T., et al.: A comparison of mechanisms for integrating handwritten and generated code for object-oriented programming languages. CoRR abs/1509.04498 (2015)Google Scholar
  18. 18.
    Greifenberg, T., et al.: Integration of Handwritten and Generated Object-Oriented Code. In: Desfray, P., Filipe, J., Hammoudi, S., Pires, L.F. (eds.) MODELSWARD 2015. CCIS, vol. 580, pp. 112–132. Springer, Cham (2015). Scholar
  19. 19.
    Haase, A., Völter, M., Efftinge, S., Kolb, B.: Introduction to openArchitectureWare 4.1. 2. In: MDD Tool Implementers Forum at TOOLS Europe (2007).
  20. 20.
    Hemel, Z., Kats, L.C.L., Groenewegen, D.M., Visser, E.: Code generation by model transformation: a case study in transformation modularity. Softw. Syst. Model. 9(3), 375–402 (2010)CrossRefGoogle Scholar
  21. 21.
    Krahn, H., Rumpe, B., Völkel, S.: MontiCore: modular development of textual domain specific languages. In: Paige, R.F., Meyer, B. (eds.) TOOLS EUROPE 2008. LNBIP, vol. 11, pp. 297–315. Springer, Heidelberg (2008). Scholar
  22. 22.
    Krahn, H., Rumpe, B., Völkel, S.: MontiCore: a framework for compositional development of domain specific languages. Int. J. Softw. Tools Technol. Transfer (STTT) 12, 353–372 (2010)CrossRefGoogle Scholar
  23. 23.
    Kundu, D., Samanta, D., Mall, R.: Automatic code generation from unified modelling language sequence diagrams. IET Softw. 7(1), 12–28 (2013)CrossRefGoogle Scholar
  24. 24.
    Mens, T., Czarnecki, K., Gorp, P.V.: A taxonomy of model transformations. In: Language Engineering for Model-Driven Software Development. Dagstuhl Seminar Proceedings. Internationales Begegnungs- und Forschungszentrum (IBFI) (2005)Google Scholar
  25. 25.
    Mir Seyed Nazari, P., Roth, A., Rumpe, B.: Mixed generative and handcoded development of adaptable data-centric business applications. In: Proceedings of the Workshop on Domain-Specific Modeling. ACM (2015)Google Scholar
  26. 26.
    Mohan, R., Kulkarni, V.: Model driven development of graphical user interfaces for enterprise business applications – experience, lessons learnt and a way forward. In: Schürr, A., Selic, B. (eds.) MODELS 2009. LNCS, vol. 5795, pp. 307–321. Springer, Heidelberg (2009). Scholar
  27. 27.
    Reiß, D.: Modellgetriebene generative Entwicklung von Web-Informationssystemen. Ph.D. thesis, RWTH Aachen University, Aachen (2015)Google Scholar
  28. 28.
    Roth, A., Rumpe, B.: Towards product lining model-driven development code generators. In: 3rd International Conference on Model-Driven Engineering and Software Development. Springer, Cham (2015)Google Scholar
  29. 29.
    Rumpe, B.: Modeling with UML. Springer, Cham (2016). Scholar
  30. 30.
    Rumpe, B., Weisemöller, I.: A domain specific transformation language. In: Workshop on Models and Evolution, vol. 11 (2011)Google Scholar
  31. 31.
    Rumpe, B.: Agile Modeling with UML: Code Generation, Testing, Refactoring. Springer, Cham (2017). Scholar
  32. 32.
    Störzer, M., Koppen, C.: PCDiff: attacking the fragile pointcut problem. In: European Interactive Workshop on Aspects in Software (2004)Google Scholar
  33. 33.
    Swint, G.S., et al.: Clearwater: extensible, flexible, modular code generation. In: 20th IEEE/ACM International Conference on Automated software engineering. ACM (2005)Google Scholar
  34. 34.
    Visser, E.: Meta-programming with concrete object syntax. In: Batory, D., Consel, C., Taha, W. (eds.) GPCE 2002. LNCS, vol. 2487, pp. 299–315. Springer, Heidelberg (2002). Scholar
  35. 35.
    Voelter, M., et al.: DSL Engineering - Designing, Implementing and Using Domain-Specific Languages (2013).
  36. 36.
    Wachsmuth, G.: A formal way from text to code templates. In: Chechik, M., Wirsing, M. (eds.) FASE 2009. LNCS, vol. 5503, pp. 109–123. Springer, Heidelberg (2009). Scholar
  37. 37.
    www: OMG UML Specification, October 2015.
  38. 38.
  39. 39.
    www: Apache maven project, August 2017.
  40. 40.
    Zschaler, S., Rashid, A.: Symmetric language-aware aspects for modular code generators. Technical Report TR-11-01, King’s College, Department of Informatics (2011)Google Scholar
  41. 41.
    Zschaler, S., Rashid, A.: Towards modular code generators using symmetric language-aware aspects. In: Proceedings of the 1st International Workshop on Free Composition. FREECO 2011, pp. 6:1–6:5. ACM, New York (2011)Google Scholar

Copyright information

© Springer Nature Switzerland AG 2019

Authors and Affiliations

  • Robert Eikermann
    • 1
    Email author
  • Katrin Hölldobler
    • 1
  • Alexander Roth
    • 1
  • Bernhard Rumpe
    • 1
  1. 1.Software EngineeringRWTH Aachen UniversityAachenGermany

Personalised recommendations