Model-Driven Software Development - Introduction & Overview

7,939 views
7,597 views

Published on

These are the slides for the introduction lecture of the course "Model-Driven Software Development" taught at Delft University of Technology in the academic year 2009-2010.

Published in: Technology

Model-Driven Software Development - Introduction & Overview

  1. 1. Model-Driven Software Development Lecture1: Introduction & Overview Course IN4308 Eelco Visser Master Computer Science http://eelcovisser.org Delft University of Technology Wednesday, February 3, 2010
  2. 2. Source: Automatiseringsgids January 16, 2010 Wednesday, February 3, 2010
  3. 3. Source: Automatiseringsgids January 16, 2010 “Generator spits out ‘mobile’ applications” “Steape has developed a code generator that automatically generates code for a range of mobile phones” Wednesday, February 3, 2010
  4. 4. Software Engineering implement Problem Solution Domain Domain validate Wednesday, February 3, 2010
  5. 5. Programming Languages Wednesday, February 3, 2010
  6. 6. "A programming language is low level when its programs require attention to the irrelevant." Alan J. Perlis. Epigrams on Programming. SIGPLAN Notices, 17(9):7-13, 1982. Wednesday, February 3, 2010
  7. 7. What do programming languages provide to reduce attention to the irrelevan? Wednesday, February 3, 2010
  8. 8. Machine Language to Assembly Language Program I-I. Disassembly. ., 0360 A9 01    LDA #$01 ., 0362 A0 00    LDY #$00 “Let's examine some advantages ., 0364 99 00 80 STA $8000,Y of ML, starting with the main ., 0367 99 00 81 STA $8100,Y one - ML runs extremely fast.” ., 036A 99 00 82 STA $8200,Y ., 036D 99 00 83 STA $8300,Y ., 0370 C8       INY ., 0371 D0 F1    BNE $0364 ., 0373 60       RTS .    Machine Language        169 1 160 0 153 0 128 153 0 129 153 130 153 0 131 200 208 241 96    BASIC        5 FOR I=1 TO 1000: PRINT "A";: NEXT I Source: http://www.atariarchives.org/mlb/introduction.php Wednesday, February 3, 2010
  9. 9. From Instructions to Expressions mov &a, &c c = a add &b, &c c += b mov &a, &t1 t1 = a sub &b, &t1 t1 -= b and &t1,&c c &= t1 c = (a + b) & (a - b) Source: http://sites.google.com/site/arch1utep/home/course_outline/translating-complex-expressions-into-assembly-language-using-expression-trees Wednesday, February 3, 2010
  10. 10. From Calling Conventions to Procedures calc: push eBP ; save old frame pointer mov eBP,eSP ; get new frame pointer sub eSP,localsize ; reserve place for locals . . ; perform calculations, leave result in AX . mov eSP,eBP ; free space for locals pop eBP ; restore old frame pointer ret paramsize ; free parameter space and return push eAX ; pass some register result push byte[eBP+20] ; pass some memory variable (FASM/TASM syntax) push 3 ; pass some constant call calc ; the returned result is now in eAX http://en.wikipedia.org/wiki/Calling_convention f(x) { ... } f(e1,e2,...,en) Wednesday, February 3, 2010
  11. 11. From Malloc/Free to Automatic Memory Management /* Allocate space for an array with ten elements of type int. */ int *ptr = (int*)malloc(10 * sizeof (int)); if (ptr == NULL) { /* Memory could not be allocated, the program should handle the error here as appropriate. */ } else { /* Allocation succeeded. Do something. */ free(ptr); /* We are done with the int objects, and free the associated pointer. */ ptr = NULL; /* The pointer must not be used again, unless re-assigned to using malloc again. */ } http://en.wikipedia.org/wiki/Malloc int [] = new int[10]; /* use it; gc will clean up (hopefully) */ Wednesday, February 3, 2010
  12. 12. Abstractions in Progamming Languages - Structured control-flow ★ if-then-else, while - Procedural abstraction ★ procedures, first-class functions (closures) - Memory management ★ garbage collection - Data abstraction ★ abstract data types, objects - Modules ★ inheritance, traits, mixins Wednesday, February 3, 2010
  13. 13. Abstraction Scala garbage collection objects Programming Languages expressions structured control-flow procedures machine Wednesday, February 3, 2010
  14. 14. Linguistic Abstraction design abstraction language A language B use new abstraction identify pattern Wednesday, February 3, 2010
  15. 15. High-level languages reduce problem/solution gap Problem HLL Machine Domain Wednesday, February 3, 2010
  16. 16. Do HLLs eliminate all irrelevant detail? What about - data persistence - data services - concurrency - distribution - access control - data invariants - workflow - ... Wednesday, February 3, 2010
  17. 17. What is the next level of abstraction? Problem HLL Machine Domain Wednesday, February 3, 2010
  18. 18. Model-Driven Software Development Problem Model HLL Machine Domain models further reduce gap between problem domain and implementation Wednesday, February 3, 2010
  19. 19. What is a model? Wednesday, February 3, 2010
  20. 20. What is a model? model thing abstraction of thing abstraction = forgetting details Wednesday, February 3, 2010
  21. 21. What is a model? “A model is a simplification of a system built with an intended goal in mind. The model should be able to answer questions in place of the actual system.” Jean Bézivin Wednesday, February 3, 2010
  22. 22. What is a model? “A model is an abstraction of a (real or language based) system allowing predictions or inferences to be made.” Kuehne Wednesday, February 3, 2010
  23. 23. What is a model? “Models help in developing artefacts by providing information about the consequences of building those artefacts before they are actually made.” Ludewig Wednesday, February 3, 2010
  24. 24. What is a model? “A model of a system is a description or specification of that system and its environment for some certain purpose.” OMG Wednesday, February 3, 2010
  25. 25. What is a model? A model - is a simplification of a system ★ abstraction, description, specification, information - can answer questions in place of actual system ★ analysis, inference, predictions - is used for a purpose ★ understanding, planing, risk analysis, ... Wednesday, February 3, 2010
  26. 26. A model is a UML diagram simplification? analysis? purpose? Wednesday, February 3, 2010
  27. 27. What is a model about? - Structure ★ Data ★ Architecture ★ Configuration - Behaviour ★ User interface ★ Access control ★ Business process - About any aspects of a system Wednesday, February 3, 2010
  28. 28. A model can be a UML diagram ... Wednesday, February 3, 2010
  29. 29. A model can be a UML diagram ... ... but it can be any other representation ... e = x | e + e | e - e | f(e,...,e) ... that serves purpose of abstraction, analysis, etc. Wednesday, February 3, 2010
  30. 30. For what purposes are models used? Description - of something that exists Analysis - understanding of properties Blueprint - guidelines to build something Specification - precise instruction for construction (code gen) Wednesday, February 3, 2010
  31. 31. Model-Driven Architecture (MDA) Vision from OMG - Models at different level of abstraction ★ Platform Independent Model (PIM) ★ Platform Specific Model (PSM) - Model transformation ★ e.g. PIM to PSM to implementation ★ transformations not necessarily automatic - UML as standard modeling language ★ models are ‘visual’ or ‘graphical’ Wednesday, February 3, 2010
  32. 32. ‘Formal Methods’ Logic Problem HLL Machine Domain Wednesday, February 3, 2010
  33. 33. A critique of MDA & formal methods General purpose modeling languages - High coverage ★ large class of software systems - Low expressivity ★ irrelevant details ★ Requirements/implementation gap not reduced Wednesday, February 3, 2010
  34. 34. Domain-Specific Languages Problem DSL HLL Machine Domain domain-specific languages: models specialized to an application domain Wednesday, February 3, 2010
  35. 35. DSLs provide domain-specific ... Abstractions ★ directly represent domain concepts Concrete syntax ★ natural notation Optimization ★ based on domain assumptions Error checking ★ report errors in terms of domain concepts Tool support ★ interpreter, compiler, code generator, IDE Wednesday, February 3, 2010
  36. 36. Example Domain-Specific Languages (1) Spreadsheet ★ formulas, macros Querying ★ SQL, XQuery, XPath Graph layout ★ GraphViz Web ★ HTML, CSS, RSS, XML, XSLT ★ Ruby/Rails, JSP, ASP, JSF, WebDSL Wednesday, February 3, 2010
  37. 37. Example Domain-Specific Languages (2) Games ★ Lua, UnrealScript Modeling ★ UML, OCL, QVT Language processing ★ YACC, LEX, RegExp, ANTLR, SDF ★ TXL, ASF+SDF, Stratego Wednesday, February 3, 2010
  38. 38. Transformation Model analysis Model migration Model construct extract System Wednesday, February 3, 2010
  39. 39. External DSL Dedicated language ★ independent of host/target language (portable) ★ implementation with interpreter or compiler Advantages ★ language tuned to domain ★ domain-specific errors, analysis, optimizations Disadvantages ★ cost of learning new language ★ cost of maintaining language Wednesday, February 3, 2010
  40. 40. Internal DSL Library in HLL ★ Haskell, Scala, Ruby, ... ★ API is language ★ language features for ‘linguistic abstraction’ Advantages ★ host language = implementation language Disadvantages ★ host language = implementation language (encoding) ★ lack of portability ★ no domain-specific errors, analysis, optimization Wednesday, February 3, 2010
  41. 41. This Course Wednesday, February 3, 2010
  42. 42. Course Goal Learn to design and implement domain-specific languages Understand DSL design choices and make reasoned decisions about their application Wednesday, February 3, 2010
  43. 43. Application DSL Domain domain analysis language definition Programming abstraction Language Patterns Design Wednesday, February 3, 2010
  44. 44. Course Ingredients Lectures (14x) Designs (2x) Cases (6x) Exams (2x) Wednesday, February 3, 2010
  45. 45. Lectures (14x) Note: no lecture in week 4, moved to week 8 Wednesday, February 3, 2010
  46. 46. Domain Analysis & Data Modeling Lecture 2 Wednesday, February 3, 2010
  47. 47. Abstractions for the Web Lectures 3-5 Wednesday, February 3, 2010
  48. 48. Language Workbenches Lecture 6 Wednesday, February 3, 2010
  49. 49. Language Modeling Lectures 6-7 Wednesday, February 3, 2010
  50. 50. Transformation, Generation, Analysis Lectures 8-10 Wednesday, February 3, 2010
  51. 51. Customization Model generate customize Code Lecture 10 Wednesday, February 3, 2010
  52. 52. Advanced Topics - Economics ★ costs and benefits of developing (with) DSLs - Evolution ★ maintenance of models and languages - Portability ★ supporting multiple platforms - Internal DSLs ★ library as a language - Language composition ★ combining multiple DSLs Lectures 12-14 Wednesday, February 3, 2010
  53. 53. Designs (2x) Wednesday, February 3, 2010
  54. 54. Designs (= lab project in pairs) Design 1 ★ Web Application with WebDSL • domain analysis • software development with a DSL Design 2 ★ DSL with Stratego & Spoofax/IMP • design and implement a DSL • use rule-based DSLs for language definition You propose web app and language to design ★ (We can give tips if you’re stuck) Wednesday, February 3, 2010
  55. 55. Cases (6x) Wednesday, February 3, 2010
  56. 56. Cases (= individual home work assignments) - Goals ★ understand and apply modeling approaches ★ solve small design problems ★ compare alternative solutions - Six cases ★ domain analysis and data modeling ★ web abstractions ★ language modeling ★ generation, transformation, analysis ★ customization ★ advanced topic Wednesday, February 3, 2010
  57. 57. Exams (2x) Wednesday, February 3, 2010
  58. 58. Exams Goals - test understanding of course material - small design problems - comparison of approaches When - midterm (after period 3) - final (after period 4) - if(midterm >= 6) { make half of final exam } Wednesday, February 3, 2010
  59. 59. Grading design := 0.4 * design1 + 0.6 * design2 exam := if(exam1 >= 6) { (exam1 + exam2)/2 } } else { exam2 } case := average(i : 1 to 6) { case[i] } final := 0.4 * design + 0.2 * case + 0.4 * exam pass := design1 >= 6 && design2 >= 6 && exam >= 6 && [c | c in case where c >= 6].length >= 4 Wednesday, February 3, 2010
  60. 60. Feedback This is a new course I’d like to get feedback early Not when it is too late to fix Volunteers for feedback group? Short meeting Thursdays at start of lab Wednesday, February 3, 2010
  61. 61. Website http://department.st.ewi.tudelft.nl/course/IN4308 Wednesday, February 3, 2010
  62. 62. Schedule Lab this week: ★ Find a partner ★ Make design proposal for a web application ★ WebDSL tutorial Read ★ Czarnecki: Overview of Generative Development ★ Muller et al.: Modeling Modeling Next week ★ Domain analysis & data modeling No lecture week 4, moved to week 8! Wednesday, February 3, 2010

×