+ All Categories
Home > Documents > IN4308 1

IN4308 1

Date post: 06-Dec-2014
Category:
Upload: eelco-visser
View: 1,213 times
Download: 0 times
Share this document with a friend
Description:
Introduction lecture for course on Model-Driven Software Development at Delft University of Technology
57
Model-Driven Software Development Course IN4308 Master Computer Science Delft University of Technology Eelco Visser http://eelcovisser.org Lecture1: Introduction & Overview
Transcript
Page 1: IN4308 1

Model-Driven Software Development

Course IN4308Master Computer Science

Delft University of Technology

Eelco Visserhttp://eelcovisser.org

Lecture1: Introduction & Overview

Page 2: IN4308 1

“Generator spits out ‘mobile’ applications”

Source: Automatiseringsgids January 16, 2010

“Steape has developed a code generator that automatically generates code for a range of mobile phones”

Page 3: IN4308 1

Software Engineering

ProblemDomain

SolutionDomain

implement

validate

Page 4: IN4308 1

Programming Languages

Page 5: IN4308 1

"A programming language is low level when its programs require attention to the irrelevant."

Programming Languages

Alan J. Perlis. Epigrams on Programming. SIGPLAN Notices, 17(9):7-13, 1982.

Page 6: IN4308 1

Machine Language to Assembly Language

   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

Program I-I. Disassembly.

., 0360 A9 01    LDA #$01

., 0362 A0 00    LDY #$00

., 0364 99 00 80 STA $8000,Y

., 0367 99 00 81 STA $8100,Y

., 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

.

Source: http://www.atariarchives.org/mlb/introduction.php

“Let's examine some advantages of ML, starting with the main one - ML runs extremely fast.”

Page 7: IN4308 1

From Instructions to Expressions

mov &a, &cadd &b, &cmov &a, &t1sub &b, &t1and &t1,&c

Source: http://sites.google.com/site/arch1utep/home/course_outline/translating-complex-expressions-into-assembly-language-using-expression-trees

c = ac += bt1 = at1 -= bc &= t1

c = (a + b) & (a - b)

Page 8: IN4308 1

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

f(e1,e2,...,en)

push eAX ; pass some register resultpush byte[eBP+20] ; pass some memory variable (FASM/TASM syntax)push 3 ; pass some constantcall calc ; the returned result is now in eAX

f(x) { ... }

http://en.wikipedia.org/wiki/Calling_convention

Page 9: IN4308 1

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) */

Page 10: IN4308 1

Abstractions in Programming 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

Page 11: IN4308 1

Abstraction

Programming Languages

procedures

expressions

garbage collection

structured control-flow

objects

machine

Scala

Abstractions in Programming Languages

Page 12: IN4308 1

Linguistic Abstraction

identify pattern

use new abstraction

language A language Bdesign abstraction

Page 13: IN4308 1

High-level languages reduce problem/solution gapWhat is the Next Level of Abstraction?

ProblemDomain HLL Machine

Page 14: IN4308 1

Do HLLs Eliminate All Irrelevant Detail?

What about

❖ data persistence

❖ data services

❖ concurrency

❖ distribution

❖ access control

❖ data invariants

❖ workflow

❖ ...

Page 15: IN4308 1

High-level languages reduce problem/solution gapWhat is the Next Level of Abstraction?

ProblemDomain HLL Machine

Page 16: IN4308 1

Model-Driven Software Development

ProblemDomain HLL MachineModel

models further reduce gap between problem domain and implementation

Page 17: IN4308 1

What is a model?

Page 18: IN4308 1

What is a model?

thingmodel

ofthing

abstraction

abstraction = forgetting details

Page 19: IN4308 1

What is a model?

“A model is a simplification of a system built with an intended goalin mind. The model should be able to answer questions in place of

the actual system.” Jean Bézivin

“A model is an abstraction of a (real or language based) systemallowing predictions or inferences to be made.” Kuehne

“Models help in developing artefacts by providing informationabout the consequences of building those artefacts before they

are actually made.” Ludewig

“A model of a system is a description or specification of that systemand its environment for some certain purpose.” OMG

Page 20: IN4308 1

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, ...

Page 21: IN4308 1

A model is a UML diagram

simplification?analysis?purpose?

Page 22: IN4308 1

What is a model about?

❖ Structure

★ Data

★ Architecture

★ Configuration

❖ Behaviour

★ User interface

★ Access control

★ Business process

❖ About any aspects of a system

Page 23: IN4308 1

A model can be a UML diagram ...

Page 24: IN4308 1

A model can be a UML diagram ...

e = x | e + e | e - e | f(e,...,e)

... but it can be any other representation ...

... that serves the purpose of abstraction, analysis, etc.

Page 25: IN4308 1

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)

Page 26: IN4308 1

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’

Page 27: IN4308 1

‘Formal Methods’ Formal Methods

ProblemDomain HLL Machine

Logic

Page 28: IN4308 1

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

Page 29: IN4308 1

Domain-Specific Languages

ProblemDomain HLL MachineDSL

domain-specific languages: models specialized to an application domain

Page 30: IN4308 1

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

Page 31: IN4308 1

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

Page 32: IN4308 1

Example Domain-Specific Languages (2)

Games

★ Lua, UnrealScript

Modeling

★ UML, OCL, QVT

Language processing

★ YACC, LEX, RegExp, ANTLR, SDF

★ TXL, ASF+SDF, Stratego

Page 33: IN4308 1

TransformationTransformation

System

ModelmigrationModel

construct

analysisModel

extract

Page 34: IN4308 1

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

Page 35: IN4308 1

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

Page 36: IN4308 1

Course Goal

Learn to design and implement domain-specific languages

Understand DSL design choices and make reasoned decisions about their application

Course Goal

Page 37: IN4308 1

abstraction

ApplicationDomain

domain analysis

ProgrammingPatterns

LanguageDesign

DSLlanguage definition

The Linguistic Abstraction Process

Page 38: IN4308 1

Lectures* (15x)

Designs (2x)

Essay (1x)

*we have 15 slots for lectures; we don’t need to use them all

Course Ingredients

Page 39: IN4308 1

Software Development with Domain-Specific Languages

Quarter 3(February - March 2011)

Page 40: IN4308 1

Extension and Evolution of DSLs

Lecture 2

Codecustomize

Model

generate

Page 41: IN4308 1

Lecture 4

WebDSL: a DSL for Web Programming

Page 42: IN4308 1

Lecture 4

Mobl: a DSL for Mobile Web Applications

Page 43: IN4308 1

Guest Lecture by Markus Voelter

Lectures 5

A Reactive State-Based DSL for Fountain Control

Page 44: IN4308 1

Guest Lecture by Sander Vermolen

Lectures 6

Automated Coupled Data Evolution

Page 45: IN4308 1

Lectures 7

Domain-Driven Design

Guest Lecture by André Boonzaaijer

(Sogyo)

Domain-Driven Design

Page 46: IN4308 1

Design1: Software Development with DSLs

Facebook

❖ Status updates selectively accessible to friends

❖ Web application in WebDSL

❖ Mobile application in mobl connected to web app using services

❖ Work in group of 2 to 4 students

Deadline: April 7

❖ submit code and arrange demonstration

Page 47: IN4308 1

Quarter 4(April - May 2011)

Design and Implementation of Domain-Specific Languages

Page 48: IN4308 1

Spoofax: a DSL for Editor Services

Lecture 8

Page 49: IN4308 1

SDF: a DSL for Syntax Definition

Lecture 8

Page 50: IN4308 1

Stratego: a DSL for Transformation

Lecture 9

Page 51: IN4308 1

Code Generation Techniques and Applications

Lecture 10

Code Generation

❖ Print statements

❖ String composition

❖ Template engines

❖ String interpolation

❖ Abstract syntax

❖ Concrete object syntax

Embedded DSLs

❖ MetaBorg, StringBorg

Page 52: IN4308 1

Advanced Topics

Lectures 11-15

❖ Portability

★ supporting multiple platforms

❖ Internal DSLs

★ library as a language

❖ Language composition

★ combining multiple DSLs

❖ Economics

★ costs and benefits of developing (with) DSLs

Page 53: IN4308 1

Design 2: Design and Implementation of DSLs

Design and implement a DSL with Spoofax

❖ use rule-based DSLs for language definition

❖ create full fledged IDE

You propose web app and language to design

❖ (We can give tips if you’re stuck)

❖ Deadline for proposal: March 22

Page 54: IN4308 1

Essay: Individual Writing Project

Read

❖ recommended papers

❖ http://researchr.org/bibliography/mdsd

Write

❖ a paper about software development with and of domain-specific languages.

★ Reflect on your experience in design projects

★ Reflect on the literature you’ve read

Page 55: IN4308 1

final grade =

❖ 0.35 * design1

❖ 0.4 * design2

❖ 0.25 * essay

all grades should be >= 6

Grading

Page 56: IN4308 1

Feedback

I’d like to get feedback early; not when it is too late to fix

Page 57: IN4308 1

Schedule

Read

❖ Czarnecki: Overview of Generative Development

❖ Muller et al.: Modeling Modeling

Lecture 2 (February 3)

❖ Extension and evolution of DSLs

Lecture 3 (February 8)

❖ WebDSL: a DSL for Web Programming

Lecture 4 (February 10)

❖ Mobl: a DSL for Mobile Web Applications


Recommended