Model-Driven Development in the context of Software Product Lines

2,220 views
2,105 views

Published on

Domain specific languages, together with code generation or interpreters (a.k.a. model-driven development), are becoming more and more important. Since there is a certain overhead involved in building languages and processors, this approach is especially useful in environments where a spe-cific set of languages and generators can be reused many times. Product lines are such an environment. Consequently, the use of domain specific languages (DSLs) for Software Product Line Engi-neering (SPLE) is becoming more relevant. However, exploiting DSLs in the context of product lines involves more than just defining and using languages. This tutorial explains the differences as well as commonalities between model-driven development (MDD) and SPLE and shows how the two approaches can be combined. In this tutorial we will first recap/introduce feature modeling and model-driven development. We then build a simple textual DSL and a code generator based on Eclipse openArchitectureWare (oAW). Based on this language we’ll discuss the kinds of variability expressible via DSLs versus those expressible via feature modeling, leading to a discussion about ways to combine the two. In the next demo slot we’ll do just that: we’ll annotate a model with feature dependencies. When generating code, the elements whose features are not selected will be removed, and hence no code will be generated. Finally we’ll discuss and demo the integration feature dependencies into code generators to con-figure the kind of code generated from the model.

Published in: Technology

Model-Driven Development in the context of Software Product Lines

  1. 1. Domain Specific Languages<br />Using<br />for<br />Product Line Engineering<br />SPLC 2009 Tutorial<br />MarkusVoelter<br />Independent/Itemis<br />www.voelter.devoelter@acm.org<br />
  2. 2. Variability<br />Configuration<br />Customization<br />MDD Intro<br />MDD Tooling<br />Model Variability<br />Transformation Var.<br />Summary & Wrapup<br />
  3. 3. Variability<br />Configuration<br />Customization<br />MDD Intro<br />MDD Tooling<br />Model Variability<br />Transformation Var.<br />Summary & Wrapup<br />
  4. 4. Variability<br />… differencesamong<br />products in PL<br />
  5. 5. Variation Point<br />… a pointwhere<br /> a variationcanoccur<br />… must beboundfor<br />eachproduct<br />… bind when?<br />… bind how?<br />
  6. 6. Binding Time<br />
  7. 7. VariabilityMechanisms<br />Removal<br />… optionallytakeaway<br />fromoverallwhole<br />
  8. 8. VariabilityMechanisms<br />Removal<br />… optionallytakeaway<br /> from overall whole<br />Challenge:<br />overallwholecan<br />get bigandunwieldy<br />
  9. 9. VariabilityMechanisms<br />Injection<br />… optionallyaddto<br /> minimal core<br />
  10. 10. VariabilityMechanisms<br />Injection<br />… optionallyaddto<br /> minimal core<br />Challenge:<br />howtopointintothecore<br />andaddsomethingtoit<br />
  11. 11. VariabilityMechanisms<br />Parametrization<br />… definevaluesfor<br />predefinedparams<br />
  12. 12. VariabilityMechanisms<br />Parametrization<br />… definevaluesfor<br />predefined params<br />Challenge:<br />typesforparameterscan<br />be non trivial (DSLs)<br />
  13. 13. Configuration vs. Customization<br />Variability<br />
  14. 14. Variability<br />Configuration<br />Customization<br />MDD Intro<br />MDD Tooling<br />Model Variability<br />Transformation Var.<br />Summary & Wrapup<br />
  15. 15. Configuration<br />… selectingoptions<br />… settingparamvalues<br />
  16. 16. Configuration<br />Feature Models<br />
  17. 17. Configuration<br />Feature Models<br />Robin DR-400<br />An aircraft with a low wing, piston engine and made of metal, wood and cloth<br />
  18. 18. Configuration<br />Feature Models<br />Airbus A 320<br />An aircraft with low wing, jet engine(s) and made of metal.<br />
  19. 19. Configuration<br />Feature Models<br />Schleicher ASW 27<br />An aircraft with shoulder wing, no engine and made of plastic<br />
  20. 20. Configuration<br />Feature Models<br />
  21. 21. Configuration<br />Feature Models<br />
  22. 22. Variability<br />Configuration<br />Customization<br />MDD Intro<br />MDD Tooling<br />Model Variability<br />Transformation Var.<br />Summary & Wrapup<br />
  23. 23. Customization<br />… „real languages“<br />… instantiation<br />… connections<br />
  24. 24. Customization<br />Languages<br />
  25. 25. Customization<br />Languages<br />
  26. 26. Customization<br />Languages<br />
  27. 27. Customization<br />Languages<br />
  28. 28. Variability<br />Configuration<br />Customization<br />MDD Intro<br />MDD Tooling<br />Model Variability<br />Transformation Var.<br />Summary & Wrapup<br />
  29. 29. programming<br />started<br />closetothehardware<br />abstractions<br /><br />computing<br />chips<br />
  30. 30. abstractions<br /><br />computing<br />bits<br />
  31. 31. abstractions<br /><br />computing<br /> C<br />
  32. 32. abstractions<br /><br />computing?<br /> Java<br />
  33. 33. abstractions<br /><br />computing?<br /> SQL<br />
  34. 34.
  35. 35. ?<br />
  36. 36.
  37. 37. generalpurpose<br />
  38. 38. domainspecific<br />
  39. 39. tailormade<br />effective++<br />specialized, limited<br />usedbyexperts<br />togetherwithother<br />specializedtools<br />
  40. 40. DSL<br />A DSL is a focussed, processablelanguage for describing a specific concern when building a system in a specific domain. The abstractions and notations used are natural/suitablefor the stakeholders who specify that particular concern.<br />
  41. 41. execute?<br />
  42. 42. map<br />
  43. 43. DSL Program<br />(aka Model)<br />map<br />automated!<br />GPL Program<br />
  44. 44. map<br />Generation<br />Transformation<br />Compilation<br />Interpretation<br />
  45. 45.
  46. 46. Automation<br />faster, deterministic<br />
  47. 47. Increased Quality<br />well definedstructuresallthroughthesystem<br />
  48. 48. Meaningful Validation<br />moresemantics in the model<br />
  49. 49. Capture<br />Domain Knowledge<br />formalizedintolanguagesandmodels<br />
  50. 50. SuitableNotations<br />textual, graphical, tabular<br />
  51. 51. Technology Independence<br />generate „technologygluecode“<br />
  52. 52. Abstraction w/o<br />Runtime Overhead<br />generator „optimizesaway“<br />
  53. 53. Capture <br />ImplementationStrategy<br />in thegenerators<br />
  54. 54. Everythingis a model<br />includingforexamplehardware (some) hardware<br />
  55. 55. Variability<br />Configuration<br />Customization<br />MDD Intro<br />MDD Tooling<br />Model Variability<br />Transformation Var.<br />Summary & Wrapup<br />
  56. 56.
  57. 57. EMF<br />Ecore meta meta model<br /> +<br />Editing<br /> Transactions<br /> Validation<br /> Query<br /> Distribution/Persistence<br />
  58. 58. EMF<br />Metamodel As Tree<br />can also be editedas UML-like diagram<br />
  59. 59. EMF<br />Constraints<br />with OCLand dialects<br />
  60. 60. GMF<br />Graphical Box/Line editors based on EMF<br />
  61. 61. TMF / Xtext<br />Building Textual Editors<br />
  62. 62. TMF / Xtext<br />Building Textual Editors<br />
  63. 63. M2M<br />Model-to-Model Transformations<br /> INRIA’s ATL<br /> QVTXtend<br />
  64. 64. M2T<br />Model-to-Text Transformations<br /> JET: Java Emitter TemplatesXpand: oAW’s<br /> template engine<br />
  65. 65. M2T<br />Model-to-Text Transformations<br /> Extensions to modularize complex expressions<br />
  66. 66. openArchitectureWare<br />www.openarchitectureware.org<br />One Stop Toolkit for DSLs + X<br />Version 5.0 is current<br />Lively ecosystem of tools and extensions<br />Proven track record in various domains & project contexts<br />Stable, productive and helpful developer, support and user communities<br />Integration with Eclipse:<br />Part of Eclipse, Working Group<br />Uses EMF as a basis<br />Graphical editors based on GMF<br />All editors and tooling based on Eclipse<br />
  67. 67. openArchitectureWare<br />
  68. 68. SpecifyGrammar<br />
  69. 69. AntlrGrammarandParserisgeneratedfromthisspecification<br />
  70. 70. Generated Metamodel<br />
  71. 71. SpecifyConstraints<br />
  72. 72. Generated Editor<br />
  73. 73. Generated Editor<br />Code Completion<br />
  74. 74. Generated Editor<br />Syntax Coloring<br />Custom KeywordColoring<br />
  75. 75. Generated Editor<br />RealtimeConstraintValidation<br />
  76. 76. Generated Editor<br />Customizable<br />Outlines<br />
  77. 77. Generated Editor<br />Code Folding<br />
  78. 78. Generated Editor<br />Goto Definition <br />Find References<br />Cross-File References<br />Model as EMF<br />
  79. 79. Generated Editor<br />
  80. 80. XtextOverview<br />
  81. 81. DEMO<br />Building a sample textual DSL and code generator for a simple domain using Eclipse TMF/openArchitectureWare<br />
  82. 82. Another Tool…?<br />OSLO<br />
  83. 83. Another Tool…?<br />
  84. 84. also do…<br />IntelliJ IDEA<br />Resharper<br />
  85. 85. released in<br />Q3 2009<br />licensed under<br />Apache 2.0<br />
  86. 86. Build new standalone DSLs<br />Build DSLs that reuse parts<br />of other languages<br />Java++<br />(MPS comes with BaseLanguage)<br />extend base language<br />build DSLs that reuse parts<br />of BaseLanguage<br />
  87. 87. Language Extension Example<br />Old<br />New<br />Java<br />Java + Extension<br />ReadWriteLock l = …<br />l.readLock().lock();<br />try {<br /> //code<br />} finally {<br /> l.readLock().unlock();<br />}<br />ReadWriteLock l = …<br />lock (l) {<br /> //code<br />}<br />
  88. 88. Structure  Editor  Typesystem  Generator<br />
  89. 89. Structure  Editor  Typesystem  Generator<br />
  90. 90. Structure  Editor  Typesystem  Generator<br />
  91. 91. Structure  Editor  Typesystem  Generator<br />
  92. 92. Structure  Editor  Typesystem  Generator<br />
  93. 93. Structure  Editor  Typesystem  Generator<br />
  94. 94. Structure  Editor  Typesystem  Generator<br />
  95. 95. Structure  Editor  Typesystem  Generator<br />
  96. 96. Language Extension Example<br />Result behaves like a native<br />base language construct<br />
  97. 97. Language Extension Example<br />Result behaves like a native<br />base language construct<br />
  98. 98. Language Extension Example<br />Translated to regular Java code<br />based on the generator<br />package jaxdemo.sandbox.sandbox;<br />import java.util.concurrent.locks.Lock;<br />public class DemoClass {<br /> private Lock lock;<br /> public DemoClass() {<br /> try {<br /> this.getLock().lock();<br /> SharedResouce.instance().doSomething();<br /> } finally {<br /> this.getLock().unlock();<br /> }<br /> }<br /> private Lock getLock() { return this.lock; }<br />}<br />
  99. 99. Example Languages<br />UI Language<br />
  100. 100. Example Languages<br />HTML Templates<br />
  101. 101. Example Languages<br />Persistent Classes<br />
  102. 102. Variability<br />Configuration<br />Customization<br />MDD Intro<br />MDD Tooling<br />Model Variability<br />Transformation Var.<br />Summary & Wrapup<br />
  103. 103. Two Levels<br />problemspace<br /> vs. softwarespace<br />Problem Space:<br />Configuration<br />Software Space:<br />Customization<br />
  104. 104. Two Levels<br />problemspace<br /> vs. softwarespace<br />
  105. 105. Two Levels<br />Removal<br />#ifdefined (ACE_HAS_TLI)staticssize_tt_snd_n( ACE_HANDLE handle,constvoid *buf, size_tlen, int flags,ACE_Time_Value *timeout = 0,size_t *bytes_transferred = 0);<br />#endif /* ACE_HAS_TLI */<br />
  106. 106. Model-Based<br />Implementation<br />… customization in<br /> problem space<br />… Problem-Space DSL<br />
  107. 107. Model-Based<br />Implementation<br />
  108. 108. Model-Based<br />Implementation<br />
  109. 109. MDSD - Thumbnail<br />
  110. 110. MD-PLE - Thumbnail<br />fewer!<br />
  111. 111. Two Levels<br />Removal<br />
  112. 112. Two Levels<br />Removal<br />
  113. 113. Two Levels<br />Removal<br />
  114. 114. Two Levels<br />Removal<br />
  115. 115. Two Levels<br />Injection<br />
  116. 116. Two Levels<br />Injection<br />aspect (*) compnent {<br />providesmon: IMonitoring<br /> }<br />
  117. 117. Two Levels<br />Removal<br />+<br />Injection<br />
  118. 118. Manual Code<br />Variability<br />public class LightDriverImplementation extends LightDriverImplBase {<br /> @Override<br /> protected String getIdInternal() {<br /> return getConfigParamValueForId();<br /> }<br /> …<br />//# dimmableLights<br /> @Override<br /> protected int setLightLevelInternal(int level) {<br /> state().setEffectiveLightLevel(level);<br /> return level;<br /> }<br />//~# dimmableLights<br />}<br />
  119. 119. http://dslvariantmanagement.googlecode.com<br />
  120. 120. DEMO<br />Extending the sample DSL to include feature-based variability connected to an external feature model<br />
  121. 121. Variability<br />Configuration<br />Customization<br />MDD Intro<br />MDD Tooling<br />Model Variability<br />Transformation Var.<br />Summary & Wrapup<br />
  122. 122. MD-PLE – Thumbnail II<br />moreoptions<br />
  123. 123. Transformation<br />Variability<br />create System transformPs2Cbd( Building building ):<br /> …<br />hasFeature(&quot;burglarAlarm&quot;) ? ( handleBurglarAlarm() -&gt; this) : this;<br />handleBurglarAlarm( System this ): <br /> let conf = createBurglarConfig(): (<br /> configurations.add( conf ) -&gt;<br /> …<br /> conf.connectors.add( connectSimToPanel( createSimulatorInstance(), createControlPanelInstance() ) ) -&gt;<br />hasFeature( &quot;siren&quot; ) ? conf.addAlarmDevice(&quot;AlarmSiren&quot;) : null -&gt;<br />hasFeature( &quot;bell&quot; ) ? conf.addAlarmDevice(&quot;AlarmBell&quot;) : null -&gt;<br />hasFeature( &quot;light&quot; ) ? conf.addAlarmDevice(&quot;AlarmLight&quot;) : null<br />);<br />
  124. 124. Transformation<br />Variability<br />
  125. 125. Generator<br />Variability<br />
  126. 126. DEMO<br />Introducing Variability into the Code Generator built before<br />
  127. 127. Variability<br />Configuration<br />Customization<br />MDD Intro<br />MDD Tooling<br />Model Variability<br />Transformation Var.<br />Summary & Wrapup<br />
  128. 128. DSLs can be used to effectively<br />describe customization variab.<br />Transformation and Generation<br />can be used to map PS to SS<br />Configuration and Customization<br />can be sensibly combined<br />Various Tools are available,<br />http://eclipse.org/modeling<br />http://dslvariantmanagement.googlecode.com/<br />
  129. 129. Domain Specific Languages<br />Using<br />Variability<br />Configuration<br />Customization<br />MDD Intro<br />MDD Tooling<br />Model Variability<br />Transformation Var.<br />Summary & Wrapup<br />for<br />Product Line Engineering<br />THE END.<br />Thankyou.<br />Questions?<br />MarkusVoelter<br />Independent/Itemis<br />www.voelter.devoelter@acm.org<br />

×