oAW Presentation

20
Pragmatic MDA: Domain Specific Languages with Eclipse Jos Warmer Partner 1

description

A beautiful presentation on oAW

Transcript of oAW Presentation

Page 1: oAW Presentation

Pragmatic MDA:

Domain Specific Languages

with Eclipse

Jos Warmer

Partner

1

Page 2: oAW Presentation

Who, why

• Expert in Model Driven Development

• One of the authors of the UML standard

– Main architect of OCL

• Written some books• Written some books

– Praktisch UML

– MDA Explained

– Object Constraint Language

• Partner at Ordina

– Responsible for MDD

– J-Technologies � SMART-Java

– Ordina Microsoft Solutions � SMART-Microsoft

Page 3: oAW Presentation

Anatomy of Domain Specific

Languages

• The abstract syntax

– The domain model or meta model

• Validation rules

– What constitutes a correct model– What constitutes a correct model

• The concrete syntax or notation

– What does the language look like

• Code generation

– Making the DSL executable

– Alternative: interpretation

3

Page 4: oAW Presentation

DSL Definition

Abstract Concrete Syntax

Validation

Rules

Code

generation

Checks /

OCL

Xtext / TMF

Concrete

Syntax

Concrete

Syntax

4

Abstract

Syntax

Concrete

Syntax

Syntax

Mapping

Syntax

Mapping

Syntax

Mapping

Ecore/EMF

Xpand / JET

/ Velocity

GMF

Page 5: oAW Presentation

Abstract Syntax

5

Page 6: oAW Presentation

Abstract Syntax

• The abstract syntax describes the concepts of

the DSL.

– These concepts come directly from the domain

• This is the vocabulary used in the domain• This is the vocabulary used in the domain

– Often exists already with the domain experts

• Usually modeled by a class diagram like notation

– E.g. UML Class models

• Also called

– Meta model by the OMG

– Domain model by Microsoft

6

Page 7: oAW Presentation

Eclipse: Ecore

Ecore

modelEditor

Java Code

generated

Editor

Runtime

EMF

model

generated

Model

Java Code

Edit

Java Code

generated

generated

generated

Model

Edit

Page 8: oAW Presentation

Validation Rules

8

Page 9: oAW Presentation

Validation rules

• The abstract syntax defines the structure

• Which instantiations of the abstract syntax are

valid?

• Specified by validation rules (or well-formedness• Specified by validation rules (or well-formedness

rules)

• E.g.

– Class names must be unique

– A class may not be a generalization of itself

9

Page 10: oAW Presentation

Validation Rules in oAW /

Checks

Ecore

model

Editor

Runtime

10

Checks

rules

Model

Edit

Constraint

checker

Page 11: oAW Presentation

Code Generation

11

Page 12: oAW Presentation

Code Generation

• Makes a DSL “executable”

– Can generate anything

12

Page 13: oAW Presentation

Code Generation with oAW

Xpand

Xpand

Templates

Editor

RuntimeXpand

Engine

Java Code

13

Ecore

model

Checks

rulesModel

Edit

Constraint

checker

HTML

XML

SQL

Etc.generated

Page 14: oAW Presentation

Concrete Syntax

14

Page 15: oAW Presentation

Concrete Syntax

• Concrete Syntax defines the “look” of the DSL

– This is the only thing that users of the DSL

actually see

• Concrete syntax is also called• Concrete syntax is also called

– Notation

– Visualization

– Surface syntax

• A DSL may have more than one concrete syntax

– Different types of users may require different

concrete syntaxes

– Concrete syntax should be designed with the user

type in mind15

Page 16: oAW Presentation

Concrete syntax

• Textual versus graphical

– … or both !

• Standalone or embedded

– This presentation is about standalone only.– This presentation is about standalone only.

• Textual: oAW Xtext

– Alternative: TCS

– Both will move (end merge) into Eclipse Textual

Modeling Framework (TMF)

• Visual: Graphical Modeling Framework (GMF)

– No real alternatives

16

xText: DSL's made easy

Jeroen Benckhuijsen,

Meinte Boersma

Page 17: oAW Presentation

Textual syntax: oAW Xtext

RuntimeXpand

Engine

Java CodeXtext

Xtext

Editor

generated

17

Ecore

model

Checks

rules

Xpand

Templates

Model

Edit

Editor

Constraint

checker

Java Code

HTML

XML

SQL

Etc.

generated

Xtext

Grammar Xtext

Editor

Page 18: oAW Presentation

Textual Concrete Syntax

• Traditional parser technology

– Uses parser generator tools• ANTRL

• JavaCC

• Lex & Yacc

Building a Domain

Specific Language

with ANTLR v3 –

• Lex & Yacc

• …

– Grammar based (EBNF)

18

Jeroen Leenarts

Page 19: oAW Presentation

Visual syntax: GMF

Xtext

RuntimeXpand

Engine

Java

What the

developer

sees

19

Ecore

model

Checks

rules

Xpand

Templates

Xtext

Grammar

GMF

Model

Model

Edit

Editor

Constraint

checker

Java

HTML

XML

SQL

Etc.

generated

Xtext

Editor

GMF

Editor

Page 20: oAW Presentation

Thanks and have fun !

Jos Warmer

[email protected]