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.
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. Software Engineering
implement
Problem Solution
Domain Domain
validate
Wednesday, February 3, 2010
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. What do programming languages provide to reduce
attention to the irrelevan?
Wednesday, February 3, 2010
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. 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. 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. 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. Abstractions in Progamming Languages
- Structured control-ļ¬ow
ā if-then-else, while
- Procedural abstraction
ā procedures, ļ¬rst-class functions (closures)
- Memory management
ā garbage collection
- Data abstraction
ā abstract data types, objects
- Modules
ā inheritance, traits, mixins
Wednesday, February 3, 2010
13. Abstraction Scala
garbage collection
objects
Programming Languages
expressions structured
control-ļ¬ow
procedures
machine
Wednesday, February 3, 2010
14. Linguistic Abstraction
design abstraction
language A language B
use new abstraction
identify pattern
Wednesday, February 3, 2010
16. Do HLLs eliminate all irrelevant detail?
What about
- data persistence
- data services
- concurrency
- distribution
- access control
- data invariants
- workļ¬ow
- ...
Wednesday, February 3, 2010
17. What is the next level of abstraction?
Problem
HLL Machine
Domain
Wednesday, February 3, 2010
18. Model-Driven Software Development
Problem
Model HLL Machine
Domain
models further reduce gap between problem domain and implementation
Wednesday, February 3, 2010
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. 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. What is a model?
āA model of a system is a description or speciļ¬cation of that system
and its environment for some certain purpose.ā OMG
Wednesday, February 3, 2010
25. What is a model?
A model
- is a simpliļ¬cation of a system
ā abstraction, description, speciļ¬cation, 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. A model is a UML diagram
simpliļ¬cation?
analysis?
purpose?
Wednesday, February 3, 2010
27. What is a model about?
- Structure
ā Data
ā Architecture
ā Conļ¬guration
- Behaviour
ā User interface
ā Access control
ā Business process
- About any aspects of a system
Wednesday, February 3, 2010
28. A model can be a UML diagram ...
Wednesday, February 3, 2010
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. For what purposes are models used?
Description
- of something that exists
Analysis
- understanding of properties
Blueprint
- guidelines to build something
Speciļ¬cation
- precise instruction for construction (code gen)
Wednesday, February 3, 2010
31. Model-Driven Architecture (MDA)
Vision from OMG
- Models at different level of abstraction
ā Platform Independent Model (PIM)
ā Platform Speciļ¬c 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. āFormal Methodsā
Logic
Problem
HLL Machine
Domain
Wednesday, February 3, 2010
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. Domain-Speciļ¬c Languages
Problem
DSL HLL Machine
Domain
domain-speciļ¬c languages: models specialized to an application domain
Wednesday, February 3, 2010
35. DSLs provide domain-speciļ¬c ...
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. Example Domain-Speciļ¬c 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. Example Domain-Speciļ¬c 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. Transformation
Model analysis Model migration Model
construct
extract
System
Wednesday, February 3, 2010
39. External DSL
Dedicated language
ā independent of host/target language (portable)
ā implementation with interpreter or compiler
Advantages
ā language tuned to domain
ā domain-speciļ¬c errors, analysis, optimizations
Disadvantages
ā cost of learning new language
ā cost of maintaining language
Wednesday, February 3, 2010
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-speciļ¬c errors, analysis, optimization
Wednesday, February 3, 2010
42. Course Goal
Learn to design and implement
domain-speciļ¬c languages
Understand DSL design choices and make
reasoned decisions about their application
Wednesday, February 3, 2010
43. Application
DSL
Domain
domain analysis
language deļ¬nition
Programming abstraction
Language
Patterns Design
Wednesday, February 3, 2010
51. Customization
Model
generate
customize Code
Lecture 10
Wednesday, February 3, 2010
52. Advanced Topics
- Economics
ā costs and beneļ¬ts 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
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 deļ¬nition
You propose web app and language to design
ā (We can give tips if youāre stuck)
Wednesday, February 3, 2010
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
58. Exams
Goals
- test understanding of course material
- small design problems
- comparison of approaches
When
- midterm (after period 3)
- ļ¬nal (after period 4)
- if(midterm >= 6) { make half of ļ¬nal exam }
Wednesday, February 3, 2010
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. Feedback
This is a new course
Iād like to get feedback early
Not when it is too late to ļ¬x
Volunteers for feedback group?
Short meeting Thursdays at start of lab
Wednesday, February 3, 2010
61. Website
http://department.st.ewi.tudelft.nl/course/IN4308
Wednesday, February 3, 2010
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