Advertisement

Springer Nature is making Coronavirus research free. View research | View latest news | Sign up for updates

Code generation by model transformation: a case study in transformation modularity

Abstract

The realization of model-driven software development requires effective techniques for implementing code generators for domain-specific languages. This paper identifies techniques for improving separation of concerns in the implementation of generators. The core technique is code generation by model transformation, that is, the generation of a structured representation (model) of the target program instead of plain text. This approach enables the transformation of code after generation, which in turn enables the extension of the target language with features that allow better modularity in code generation rules. The technique can also be applied to ‘internal code generation’ for the translation of high-level extensions of a DSL to lower-level constructs within the same DSL using model-to-model transformations. This paper refines our earlier description of code generation by model transformation with an improved architecture for the composition of model-to-model normalization rules, solving the problem of combining type analysis and transformation. Instead of coarse-grained stages that alternate between normalization and type analysis, we have developed a new style of type analysis that can be integrated with normalizing transformations in a fine-grained manner. The normalization strategy has a simple extension interface and integrates non-local, context-sensitive transformation rules. We have applied the techniques in a realistic case study of domain-specific language engineering, i.e. the code generator for WebDSL, using Stratego, a high-level transformation language that integrates model-to-model, model-to-code, and code-to-code transformations.

References

  1. 1

    Google App Engine—Google Code.: http://code.google.com/appengine/ (2008)

  2. 2

    Kraus, A.K.A., Koch, N.: Model-driven generation of web applications in UWE. In: Model-Driven Web Engineering (MDWE’07), Como, Italy, July (2007)

  3. 3

    AndroMDA.org.: AndroMDA documentation. http://galaxy.andromda.org (2007)

  4. 4

    Balland, E., Brauner, P.: Term-graph rewriting in Tom using relative positions. Electronic Notes in Theoretical Computer Science, vol. 203(1), pp. 3–17. Proceedings of the Fourth International Workshop on Computing with Terms and Graphs (TERMGRAPH 2007) (2008)

  5. 5

    Balland E., Brauner P., Kopetz R., Moreau P., Reilles A.: Tom: Piggybacking Rewriting on Java. Lecture Notes in Computer Science 4533, 36–47 (2007)

  6. 6

    Bast, W., Belaunde, M., Blanc, X., Duddy, K., Griffin, C., Helsen, S., Lawley, M., Murphree, M., Reddy, S., Sendall, S., Steel, J., Tratt, L., Venkatesh, R., Vojtisek, D.: MOF QVT Final Adopted Specification, Nov 2005. OMG document ptc/05-11-01

  7. 7

    Bézivin J.: On the unification power of models. Softw. Syst. Model. 4(2), 171–188 (2005)

  8. 8

    Bézivin, J.: Model driven engineering: an emerging technical space. In: Lämmel, R., Saraiva, J., Visser, J. (eds) GTTSE, volume 4143 of Lecture Notes in Computer Science, pp. 36–64. Springer, Heidelberg (2006)

  9. 9

    van den Brand M.G.J., de Jong H., Klint P., Olivier P.: Efficient annotated terms. Softw. Prac. Exp. 30(3), 259–291 (2000)

  10. 10

    Bravenboer M., Kalleberg K.T., Vermaas R., Visser E.: Stratego/XT 0.17. A language and toolset for program transformation. Sci. Comp. Programm. 72(1–2), 52–70 (2008)

  11. 11

    Bravenboer M., van Dam A., Olmos K., Visser E.: Program transformation with scoped dynamic rewrite rules. Fund. Inform. 69(1–2), 123–178 (2006)

  12. 12

    Budinsky F., Steinberg D., Merks E., Ellersick R., Grose T.J.: Eclipse Modeling Framework (The Eclipse Series). Addison-Wesley, Reading (2003)

  13. 13

    Burns, E., Kitain, R. (eds).: JavaServer Faces Specification. Version 1.2. Sun Microsystems (2006)

  14. 14

    Cook S., Jones G., Kent S., Wills A.C.: Domain-Specific Development with Visual Studio DSL Tools. Addison-Wesley, Reading (2007)

  15. 15

    Cordy J.: The TXL source transformation language. Sci. Comput. Programm. 61(3), 190–210 (2006)

  16. 16

    Coward, D., Yoshida, Y.: Java Servlet Specification. Version 2.4. Sun Microsystems (2003)

  17. 17

    Czarnecki K., Helsen S.: Feature-based survey of model transformation approaches. IBM Syst. J. 45(3), 621–645 (2006)

  18. 18

    DeMichiel, L., Keith, M. (eds.).: JSR 220: Enterprise JavaBeans, Version 3.0. EJB Core Contracts and Requirements. Sun Microsystems (2006)

  19. 19

    DeMichiel, L., Keith, M. (eds.).: JSR 220: Enterprise JavaBeans, Version 3.0. Java Persistence API. Sun Microsystems (2006)

  20. 20

    Efftinge, S., Friese, P.: openArchitectureWare. http://www.eclipse.org/gmt/oaw (2007)

  21. 21

    Efftinge, S., Friese, P., Haase, A., Kadura, C., Kolb, B., Moroff, D., Thoms, K., Völter, M.: openArchitectureWare User Guide. Version 4.2. http://www.openarchitectureware.org (2007)

  22. 22

    Efftinge, S., Völter M.: oAW xText—a framework for textual DSLs. In: Modeling Symposium, Eclipse Summit (2006)

  23. 23

    Ekman T., Hedin G.: Rewritable reference attributed grammars. In: Odersky, M., editor, 18th European Conference Object-Oriented Programming (ECOOP 2004), volume 3086 of Lecture Notes in Computer Science, pp. 144–169, Oslo, Norway, July, Springer (2004)

  24. 24

    Gray R.W., Levi S.P., Heuring V.P., Sloane A.M., Waite W.M.: Eli: a complete, flexible compiler construction system. Commun. ACM 35(2), 121–130 (1992)

  25. 25

    Groenewegen D.M., Visser E.: Declarative access control for WebDSL: Combining language integration and separation of concerns. In: Schwabe, D., Curbera, F. (eds) Eighth International Conference on Web Engineering (ICWE 2008), pp. 175–188. IEEE CS Press, New York (2008)

  26. 26

    Hemel, Z., Kats, L.C.L., Visser, E.: Code generation by model transformation. A case study in transformation modularity. In: Gray, J., Pierantonio, A., Vallecillo, A. (eds.) Theory and Practice of Model Transformations. First International Conference on Model Transformation (ICMT 2008), volume 5063 of Lecture Notes in Computer Science, pp. 183–198, Springer, Heidelberg (2008)

  27. 27

    Hemel, Z., Verhaaf, R., Visser, E.: WebWorkFlow: an object-oriented workflow modeling language for web applications. In: Czarnecki, K., Ober, I., Bruel, J.-M., Uhl, A., Völter, M. (eds.) Proceedings of the 11th International Conference on Model Driven Engineering Languages and Systems (MODELS 2008), volume 5301 of Lecture Notes in Computer Science, pp. 113–127, Springer, Heidelberg, 2008

  28. 28

    Huang, S.S. Smaragdakis, Y.: Easy language extension with Meta-AspectJ. In: ICSE ’06: Proceeding of the 28th International Conference on Software Engineering, pp. 865–868. ACM, New York (2006)

  29. 29

    Janssenn, N.: Transformation tool composition. Master’s thesis, Institute of Information and Computing Sciences Utrecht University, Utrecht, The Netherlands (2005)

  30. 30

    Jouault F., Bézivin, J.: KM3: a DSL for metamodel specification. In: Formal Methods for Open Object-Based Distributed Systems, volume 4037 of LNCS, pp. 171–185, Bologna, Italy, Springer, Heidelberg (2006)

  31. 31

    Jouault, F., Bézivin, J., Kurtev, I.: TCS: a DSL for the specification of textual concrete syntaxes in model engineering. In: Generative Programming and Component Engineering (GPCE’06), pp. 249–254. ACM, New York (2006)

  32. 32

    Jouault, F., Kurtev, I. Transforming models with ATL. In: Satellite Events at the MoDELS 2005 Conference, volume 3844 of LNCS, pp. 128–138. Springer, Heidelberg (2006)

  33. 33

    Kats, L.C.L., Bravenboer, M., Visser, E.: Mixing source and bytecode. A case for compilation by normalization. In: Kiczales, G., (ed.) Proceedings of the 23rd ACM SIGPLAN Conference on Object-Oriented Programing, Systems, Languages, and Applications (OOPSLA 2008), pp. 91–108, October. ACM, New York (2008)

  34. 34

    Kats, L.C.L., Kalleberg, K.T., Visser, E.: Domain-specific languages for composable editor plugins. In: Ekman, T., Vinju, J., (eds.) Proceedings of the Ninth Workshop on Language Descriptions, Tools, and Applications (LDTA 2009), Electronic Notes in Theoretical Computer Science. Elsevier, Amsterdam, 2009 (to appear)

  35. 35

    Kelly, S., Lyytinen, K., Rossi, M.: MetaEdit+: a fully configurable multi-user and multi-tool CASE and CAME environment. In: CAiSE, pp. 1–21 (1996)

  36. 36

    Kelly S., Tolvanen J.-P.: Domain-Specific Modeling. Enabling Full Code Generation. Wiley, New York (2008)

  37. 37

    Kittoli, S. (ed). Seam—Contextual Components. A Framework for Enterprise Java. Red Hat Middleware, LLC (2008)

  38. 38

    Klint P.: A meta-environment for generating programming environments. ACM Trans. Softw. Eng. Methodol. 2(2), 176–201 (1993)

  39. 39

    Kulkarni, V., Reddy, S.: An abstraction for reusable mdd components: model-based generation of model-based code generators. In: GPCE ’08: Proceedings of the 7th International Conference on Generative Programming and Component Engineering, pp. 181–184. ACM, New York (2008)

  40. 40

    Kurtev, I., Bézivin, J., Jouault, F., Valduriez, P.: Model-based DSL frameworks. In: Companion to OOPSLA’06, pp. 602–616. ACM, New York (2006)

  41. 41

    Brambilla, P.F.M., Comai, S., Matera, M.: Designing web applications with WebML and WebRatio. In: Rossi, G. et al. (eds.) Web Engineering: Modelling and Implementing Web Applications, Human–Computer Interaction Series. Springer, October (2007)

  42. 42

    Mens, T., van Gorp, P.: A taxonomy of model transformation. In: Graph and Model Transformation (GraMoT 2005), vol. 152, pp. 125–142 (2006)

  43. 43

    Pastor, V.P.O., Fons, J.: OOWS: a method to develop web applications from web-oriented conceptual models. In: Web Oriented Software Technology (IWWOST’03), pp. 65–70 (2003)

  44. 44

    Object Management Group (OMG).: OMG/RFP/QVT MOF 2.0 query/views/transformations RFP, (2003)

  45. 45

    Object Management Group (OMG).: Meta object facility (MOF) core specification. OMG available specification. Version 2.0. http://www.omg.org (2006)

  46. 46

    Cáceres, B.V.P., Marcos, E.: A MDA-based approach for web information system development. In: Proceedings of Workshop in Software Model Engineering (2003)

  47. 47

    Paakki J.: Attribute grammar paradigms—a high-level methodology in language implementation. ACM Comput. Surv. (CSUR) 27(2), 196–255 (1995)

  48. 48

    Parr, T.J.: Enforcing strict model-view separation in template engines. In: WWW ’04: Proceedings of the 13th International Conference on World Wide Web, pp. 224–233, New York (2004)

  49. 49

    Peyton Jones, S. (eds): Haskell98 Language and Libraries. The Revised Report. Cambridge University Press, Cambridge (2003)

  50. 50

    Peyton Jones S.L., Santos A.L.M.: A transformation-based optimiser for Haskell. Sci. Comp. Programm. 32(1–3), 3–47 (1998)

  51. 51

    Pierre-Alain Muller F.F., Studer P., Bézivin J.: Platform independent web application modeling and development with Netsilon. Softw. Syst. Model. 4(4), 424–442 (2005)

  52. 52

    Sarkar, D., Waddell, O., Dybvig, R.K.: A nanopass infrastructure for compiler education. In: ICFP ’04: Proceedings of the Ninth ACM SIGPLAN International Conference on Functional Programming, pp. 201–212. ACM, New York (2004)

  53. 53

    Schmidt D.C.: Model-driven engineering. IEEE Comp. 39(2), 25–31 (2006)

  54. 54

    Stahl T., Völter M.: Model-Driven Software Development. Wiley, New York (2005)

  55. 55

    Suzuki, J., Yamamoto, Y.: Extending UML with aspects: aspect support in the design phase. Lecture Notes in Computer Science, pp. 299–299 (1999)

  56. 56

    The Apache Foundation. Velocity User Guide. http://velocity.apache.org/engine/devel/user-guide.html (2007)

  57. 57

    van Deursen A., Klint P., Tip F.: Origin tracking. J. Symbol. Comput. 15(5/6), 523–545 (1993)

  58. 58

    Visser, E.: Syntax Definition for Language Prototyping. Ph.D. Thesis, University of Amsterdam (1997)

  59. 59

    Visser, E.: Meta-programming with concrete object syntax. In: Batory, D., Consel, C., Taha, W. (eds.) Generative Programming and Component Engineering (GPCE 2002), volume 2487 of Lecture Notes in Computer Science, pp. 299–315, Pittsburgh. Springer, Heidelberg (2002)

  60. 60

    Visser, E.: Program transformation with Stratego/XT: Rules, strategies, tools, and systems in StrategoXT-0.9. In: Lengauer, C., et al. (eds.) Domain-Specific Program Generation, volume 3016 of Lecture Notes in Computer Science, pp. 216–238. Spinger, Heidelberg (2004)

  61. 61

    Visser, E.: A survey of strategies in rule-based program transformation systems. J. Symbol. Comput. 40(1):831–873 (2005). Special issue on Reduction Strategies in Rewriting and Programming

  62. 62

    Visser, E.: WebDSL: A case study in domain-specific language engineering. In: Lämmel, R., Visser, J., Saraiva, J. (eds.) International Summer School on Generative and Transformational Techniques in Software Engineering (GTTSE 2007), volume 5235 of Lecture Notes in Computer Science, pp. 291–373. Springer, Heidelberg (2008)

  63. 63

    Visser, E., Benaissa, Z.-E.-A., Tolmach, A.: Building program optimizers with rewriting strategies. In: Proceedings of the Third ACM SIGPLAN International Conference on Functional Programming (ICFP 1998), pp. 13–26. ACM, New York (1998)

  64. 64

    Voelter, M., Groher, I.: Handling Variability in Model Transformations and Generators. In: Domain-Specific Modeling (DSM’07) (2007)

  65. 65

    Warmer, J.B., Kleppe A.G.: Building a flexible software factory using partial domain specific models. In: Domain-Specific Modeling (DSM’06), Portland, Oregon, USA, pp. 15–22 (2006)

  66. 66

    van Wijngaarden, J., Visser, E.: Program Transformation Mechanics. A Classification of Mechanisms for Program Transformation with a Survey of Existing Transformation Systems. Technical Report UU-CS-2003-048, Institute of Information and Computing Sciences, Utrecht University (2003)

  67. 67

    Wyk, E. V., Krishnan, L., Bodin D., Schwerdfeger, A.: Attribute Grammar-Based Language Extensions for Java. In: Ernst E. (ed.) 21st European Conference on Object-Oriented Programming (ECOOP 2007), volume 4609 of Lecture Notes in Computer Science, pp. 575–599, Berlin, Springer, Germany (2007)

  68. 68

    Zook, D., Huang, S.S., Smaragdakis, Y.: Generating AspectJ Programs with Meta-AspectJ. In: Karsai, G. Visser, E. (eds.) Generative Programming and Component Engineering: Third International Conference, GPCE 2004, Vancouver, Canada, October 24-28, 2004. Proceedings, volume 3286 of Lecture Notes in Computer Science, pp. 1–18. Springer, Heidelberg (2004)

Download references

Acknowledgments

We would like to thank the anonymous reviewers of ICMT 2008 and SOSYM for their comments on earlier versions of this paper. This research was supported by NWO/JACQUARD project 638.001.610, MoDSE: Model-Driven Software Evolution, and 612.063.512, TFA: Transformations for Abstractions.

Open Access

This article is distributed under the terms of the Creative Commons Attribution Noncommercial License which permits any noncommercial use, distribution, and reproduction in any medium, provided the original author(s) and source are credited.

Author information

Correspondence to Eelco Visser.

Additional information

Communicated by Jeff Gray, Alfonso Pierantonio, and Antonio Vallecillo.

Rights and permissions

Open Access This is an open access article distributed under the terms of the Creative Commons Attribution Noncommercial License (https://creativecommons.org/licenses/by-nc/2.0), which permits any noncommercial use, distribution, and reproduction in any medium, provided the original author(s) and source are credited.

Reprints and Permissions

About this article

Cite this article

Hemel, Z., Kats, L.C.L., Groenewegen, D.M. et al. Code generation by model transformation: a case study in transformation modularity. Softw Syst Model 9, 375–402 (2010). https://doi.org/10.1007/s10270-009-0136-1

Download citation

Keywords

  • Transformation
  • Transformation engineering
  • Term rewriting
  • Webapplication DSL
  • Combination of analysis and transformation