Concrete Syntax Definition for Modeling Languages

Nov 2, 2007 - Models at any abstraction level. • Use cases, Business models, SDL, CCM, B, … .... name : String. StateMachine. StateVertex. Transition. State.
1MB taille 2 téléchargements 453 vues
Concrete Syntax Definition for Modeling Languages Frédéric Fondement PhD. thesis Public Defense Swiss Federal Institute of Technology in Lausanne Software Engineering Laboratory November 2007

Contents z Introduction • Software Engineering • Model Driven Engineering • Language Definition

z Concrete Syntaxes • Textual concrete syntax definition • Graphical concrete syntax definition

z Conclusions and outlook

© F. Fondement

-2-

November 2007

Productivity Gains in SE z Methodologies • • • • • • • • •

z Abstraction Techniques

SADT Fusion OMT Booch Catalysis RUP Fondue SEAM …

• Punched Cards • Assembly Code • Functional / Procedural Programming • Object-Oriented Programming • Patterns • Concurrent Programming • Component-Oriented Programming / Middleware • Design by Contracts • Aspect-Oriented Programming • Product Family Engineering • …

Made possible/necessary thanks to/because of evolution of hardware…

© F. Fondement

-3-

November 2007

Consequence: Production Gains Complexity (LOC) 108

1959: ALGOL 1963: COBOL

1983: ADA 83

107 106

Windows 2000

GSM Networks

1997: AOP 1972: SmallTalk

Nuclear Submarine Control

1994: GOF 1993: Booch 93

Packet Switching System

105 104

1991: CORBA

Compilers

1965

Functionnal Procedural

1976: SADT 1975

1992: Catalysis 1992: Design By Contracts 1985

OO

1995

Components

2005

Age

Remark: A new paradigm needs around 10 years to be mature © F. Fondement

-4-

November 2007

Major Lessons z SE Best Practices • • • • •

Reuse / Develop for reuse Refinement / Refactoring Prototyping Test / Verification / Validation Communication / Documentation

z Problems

• Requirements change

• Nokia: 50% changed after finalization ; 60% of them at least twice

• Platforms change

• OS, Languages, Databases, Middleware, …

• Development technology change

• Compilers, Code generators, Frameworks, …

• People change

• Especially for systems developed 30 years ago !

© F. Fondement

-5-

November 2007

Models z Abstract away details

• Use paradigms rather than technologies • Enhance productivity and production !

z Human friendly

• Different views of the same system

z Cheap to manipulate and maintain z Models at any abstraction level

• Use cases, Business models, SDL, CCM, B, …

Used most of the time for z Documentation / communication z Analysis z Prototyping Often drawings out of sync with (code) reality ! © F. Fondement

-6-

November 2007

Im p

ro v em

en ts

Software Engineering Abstraction

System System System System System

Platform/s Specificities

• Test • Validation • Verification © F. Fondement

• Iteration ≠ • Level of Abstraction ≠ • Level of Detail -7-

November 2007

Contents z Introduction • Software Engineering • Model Driven Engineering • Language Definition

z Concrete Syntaxes • Textual concrete syntax definition • Graphical concrete syntax definition

z Conclusions

© F. Fondement

-8-

November 2007

SE with Models Model Driven Engineering (MDE) “From contemplative to productive” Organizes abstraction

en ts

Automation

Transformation Transformation

Im p

Transformation

ro v em

Transformation

Code Generator

System System System System System

Model Model Model Model Model

Code Generation System

Code

• Test → GENERATION • Validation → PROTOTYPING • Verification → MODEL CHECKING © F. Fondement

-9-

November 2007

en ts

Model Driven Engineering

Transformation Transformation

Im p

Transformation

ro v em

Transformation

Code Generator

System System System System System

Model Model Model Model Model

Code Generation System

Code

• Test → GENERATION • Validation → PROTOTYPING • Verification → MODEL CHECKING © F. Fondement

- 10 -

November 2007

M2

Definition Level (method)

Model Driven Engineering

Source Languages (Metamodels)

M1

Application Level (project)



Model Transformation

m e t s eym S t s e y rc S u o S

© F. Fondement

Target Languages (Metamodels)

em t s m y te S s t y e gS Tar Set up @4537H Mov ah, up Int 4CH

- 11 -

November 2007

M2

Definition Level (method)

Model Driven Engineering

Source Languages (Metamodels)

M1

Application Level (project)



Model Transformation

m e t s eym S t s e y rc S u o S

© F. Fondement

Target Languages (Metamodels)

em t s m y te S s t y e gS Tar Set up @4537H Mov ah, up Int 4CH

- 12 -

November 2007

Questions Raised z What language for describing systems ? • E.g. E-Banking

• From Use Cases… • …to Oracle Schema + EJB + JSP

• E.g. Subway

• From Use Cases… • … to Wireless JavaCard

• …

z One unique language is not enough !

• Domain Specific Languages • Small languages

• Define YOURSELF the right level of abstraction !

Domain Specific Modeling

© F. Fondement

- 13 -

November 2007

Questions Raised Domain Specific Modeling =

Proliferation of languages ! • Support for language engineering

© F. Fondement

- 14 -

November 2007

Contents z Introduction • Software Engineering • Model Driven Engineering • Language Definition

z Concrete Syntaxes • Textual concrete syntax definition • Graphical concrete syntax definition

z Conclusions

© F. Fondement

- 15 -

November 2007

Language Definition

Concepts

M2

Meaning

Language

Interface

© F. Fondement

- 16 -

November 2007

Concepts Definition

M2

Abstract Syntax

ModelElement name : String

StateMachine source subvertex *

StateVertex

Event

outgoing

1

*

1

*

target

trigger 0..1 Transition

*

incoming top 1 State

PseudoState

«enumeration» PseudoStateKind

kind : PseudoStateKind container 0..1

Composite State

© F. Fondement

Simple State

Final State

initial choice ...

- 17 -

November 2007

Concepts Definition Abstract Syntax

M1

:StateMachine

ModelElement

:CompositeState

name : String

StateMachine source subvertex *

StateVertex

Event

outgoing

1

*

1

*

target

trigger 0..1 Transition

«enumeration» PseudoStateKind

kind : PseudoStateKind container 0..1

Composite State

Simple State

Final State

target closed:CompositeState

subvertex :Transition

:PseudoState

incoming

State

subvertex

*

top 1 PseudoState

root

initial choice ...

kind=initial

:PseudoState subvertex kind=initial

source :Transition

source subvertex

target

source

:Transition

opened:SimpleState target

target unlocked:SimpleState source

:Transition

subvertex

:Transition

An (M1) sentence => source

target

locked:SimpleState subvertex

© F. Fondement

- 18 -

November 2007

Interface Definition

M2

Abstract Syntax + Concrete Syntax(es) sm ::= "Statemachine" IDENT compositeState

ModelElement name : String

state ::= normalState | pseudostate

StateMachine source subvertex *

StateVertex

Event

outgoing *

1

*

1 target

trigger 0..1 Transition

*

simpleState ::= "State" IDENT

top 1 State

PseudoState

«enumeration» PseudoStateKind

kind : PseudoStateKind container 0..1

Composite State

normalState ::= "initial"? (simpleState | compositeState)

incoming

Simple State

Final State

initial choice ...

compositeState ::= "CompositeState IDENT? LCURLYBRACKET (state | transition)* RCURLYBRACKET transition ::= "Transition" IDENT? "from" IDENT "to" IDENT ("on" IDENT)? pseudoState ::= "FinalState" IDENT | "Choice" IDENT

© F. Fondement

- 19 -

November 2007

Interface Definition

M1

Abstract Syntax + Concrete Syntax(es) sm ::= "Statemachine" IDENT compositeState

ModelElement name : String

state ::= normalState | pseudostate StateMachine source subvertex *

StateVertex

Event

outgoing

1

*

1

*

target

trigger 0..1 Transition

simpleState ::= "State" IDENT

incoming top 1 State

PseudoState

«enumeration» PseudoStateKind

kind : PseudoStateKind container 0..1

Composite State

Simple State

Final State

normalState ::= "initial"? (simpleState | compositeState)

*

initial choice ...

compositeState ::= "CompositeState IDENT? LCURLYBRACKET (state | transition)* RCURLYBRACKET transition ::= "Transition" IDENT? "from" IDENT "to" IDENT ("on" IDENT)?

StateMachine Door pseudoState ::= "FinalState" IDENT | "Choice" CompositeState { initial State opened CompositeState closed { initial State unlocked State locked isEmpty() then self.vo.event.text.size() = 0 else self.vo.event.text = self.me.trigger.name endif

© F. Fondement

1

1 «connects» SVGArrowEnd start

Event

Transition

vo

- 51 -

1 SVGText «nearby» event text:String

November 2007

Graphical concrete syntax definition z Concrete syntax model DOM interaction library

Mapping

SVG Templates

Graphical Syntax (Metamodel)

Abstract Syntax (Metamodel) «conformsTo»

z Concrete syntax graphical design • • • •

Model SVG Renderer «conformsTo» «conformsTo»

SVG Document

• Fixes concrete syntax elements • Fixes relationship with abstract syntax

Fixes appearance Fixes layout constraints Fixes edition facilities Fixes link with concrete syntax model

Representation Data

© F. Fondement

- 52 -

November 2007

Solving appearance Graphical Syntax

SVGCompositeState name:SVGText separator:SVGLine



SVGTransition 1 «connects» SVGArrowEnd start 1 «connects» SVGArrowEnd end 1 SVGText «nearby» event text:String

contents:SVGContents

SVGSimpleState 1 «contains» name

SVGText

SVGComposite State 1 0..1 «contains» name

SVGText

0..1 «contains» separator

SVGLine

0..1 «contains» contents

SVGContents

...

© F. Fondement

- 53 -

November 2007

Solving appearance Graphical Syntax

SVGCompositeState name:SVGText separator:SVGLine



SVGTransition 1 «connects» SVGArrowEnd start 1 «connects» SVGArrowEnd end 1 SVGText «nearby» event text:String

SVGSimpleState 1 «contains» name

SVGText

SVGComposite State 1 0..1 «contains» name

SVGText

0..1 «contains» separator

SVGLine

0..1 «contains» contents

SVGContents

...

© F. Fondement

contents:SVGContents

< g id=“$$” …> … - 54 -

November 2007

Solving appearance Graphical Syntax SVGTransition 1 «connects» SVGArrowEnd start



1 «connects» SVGArrowEnd end 0..1 SVGText «nearby» event text:String

SVGSimpleState 1 «contains» name

SVGText

SVGPseudo State SVGInitial

...



© F. Fondement

- 57 -

November 2007

Graphical concrete syntax definition z Concrete syntax model DOM interaction library

Mapping

SVG Templates

Graphical Syntax (Metamodel)

Abstract Syntax (Metamodel) «conformsTo»

z Concrete syntax graphical design • • • •

Model SVG Renderer «conformsTo» «conformsTo»

SVG Document

• Fixes concrete syntax elements • Fixes relationship with abstract syntax

Fixes appearance Fixes layout constraints Fixes edition facilities Fixes link with concrete syntax model

Representation Data

© F. Fondement

- 58 -

November 2007

DopiDOM components library Interface

Interface

BorderSlidable

Stickable

DirectionAdjustable

Translatable

Locatable

BorderFindable

Positionable

OriginGettable

Containable

Container

Editable

© F. Fondement

edi|

0

Etc…

- 59 -

November 2007

Solving edition facilities CompositeState template

© F. Fondement

- 60 -

November 2007

Graphical concrete syntax definition z Concrete syntax model DOM interaction library

Mapping

SVG Templates

Graphical Syntax (Metamodel)

Abstract Syntax (Metamodel) «conformsTo»

z Concrete syntax graphical design • • • •

Model SVG Renderer «conformsTo» «conformsTo»

SVG Document

• Fixes concrete syntax elements • Fixes relationship with abstract syntax

Fixes appearance Fixes layout constraints Fixes edition facilities Fixes link with concrete syntax model

Representation Data

© F. Fondement

- 61 -

November 2007

Representation Link: DopiDOM events z Events depend on DopiDOM component z Reaction to events defined in templates • Java JMI or EMF, KerMETA, Xion, etc.

z Initial / Load / Save scripts

CompositeState template

© F. Fondement

- 62 -

November 2007

Representation Link: Value events z One listener synchronizing

• An attribute value on the model with • an attribute value on the SVG document

CompositeState template revisited © F. Fondement

- 63 -

Graphical Syntax (Metamodel) «conformsTo» Representation Data

November 2007

Separation of concerns Graphical Syntax (Metamodel)

Graphical Editor ↑ Relates a model and a graphical representation

© F. Fondement

Abstract Syntax (Metamodel)

Mapper

Model Repository

↑ z Avoids Relates two things abstract/concrete of same nature syntax pollution

z Improves reusability z Minimizes maintenance points z Mapping can be complex (large gap !)

- 64 -

November 2007

Contents z Model Driven Engineering z Concrete Syntaxes • Textual concrete syntax definition • Graphical concrete syntax definition

z Conclusions

© F. Fondement

- 65 -

November 2007

Conclusions z Language proliferation (MDE+DSM) • Language engineering is a key

z Solutions to fill abstract/concrete syntax gap • Abstract syntax provided as a metamodel • Focus on executable specifications • Human readable/producible ?

© F. Fondement

- 66 -

November 2007

Contributions

Abstract Syntax (Metamodel)

Textual Concrete Syntax Spec.

«conformsTo»

z Textual concrete syntax • “mapping” metamodel

Model

«conformsTo»

Reversible Text Processor

Text

z Approach to graphical concrete syntax specification • Metamodel for representation data • Interface for the concrete syntax

• Mapping to abstract syntax

Graphical Editor

Graphical Syntax (Metamodel)

Abstract Syntax (Metamodel)

Mapper

Model Repository

z Technology for graphical concrete syntax realization • Representation using SVG templates • Library of possible user interactions



z Other technologies apply • (Triple) Graph Grammars • GMF, Topcased, … © F. Fondement

- 67 -

November 2007

Analytic –vs.– Interactive CS z Solutions to textual and graphical CS are very different • Textual • Graphical

=> usually analytic => usually interactive

(with small gap) (from no gap to large gap)

z Unification of solutions ? z Inversion of solutions ?

© F. Fondement

- 68 -

November 2007

Towards “Agile” Language Engineering z Agile MDE Definition • Knowledge from real specialists ! • “off-the-shelf (MDE) components” • Adaptable to each project

Compiler Provider

CASE tool Provider

Language Engineering

Domain Engineer

«include»

Language Composition «include» Language Tuning

Project Architect

© F. Fondement

- 69 -

November 2007

Tuning MDE Artefacts

Tuned Very Abstract Metamodel

Very Abstract Metamodel

«model transformation» Pass 1 «Weaves In»

«model transformation aspect» Tuned Pass 1

*

Tuned Decorated Metamodel

Less Abstract Metamodel

«model transformation» Pass N

Tuned Concrete Metamodel

«Weaves In» «model transformation aspect» Tuned Pass N

© F. Fondement

- 70 -

Concrete Metamodel

November 2007

Thank you !

© F. Fondement

- 71 -

November 2007