DSL
Domain Specific Language
À l'aide des technologies Eclipse Modeling
Le 29 juin 2010
Jérôme [email protected]
© C
op
yri
ght
20
10
O
beo
Le but de cette session
Montrer :
Ce qu'est-un DSL/DSM
A quoi ça sert
Comment implémenter des Domain-Specific Languages en utilisant le projet Eclipse Modeling
© C
op
yri
ght
20
10
O
beo
Agenda
Qui suis-je où suis-je ?
Les DSL en général
Les DSL textuels
Les DSL graphiques
Conclusion
© C
op
yri
ght
20
10
O
beo
Jérôme BENOIS10 ans de Java...
Architecte – "Model Driven Expert" à
Responsable Obeo Network
Committer , , EasyAnt, Bushel
Forte implication dans le monde Open-Source (contributions à Eclipse GMT/MoDisco, C-JDBC, UML2SVG, membre de l'OSS-GTP, ...)
Niortais et Poitou-Charentes JUG addict :)
http://blog.benois.fr & http://twitter.com/jeromebenois
© C
op
yri
ght
20
10
O
beo
ObeoÉditeur spécialiste des approches modèles
Nantes en 2005, Paris depuis 2007
40 spécialistes MDE
Activité 2009 : 2,5 M€ en croissance de 50%
Société Française indépendante
Investissement R&D à hauteur de 30% des revenus
© C
op
yri
ght
20
10
O
beo
Les DSL en général
© C
op
yri
ght
20
10
O
beo
DSL ?
: "In software development and domain engineering, a domain-specific language (DSL) is a programming language or specification language dedicated to a particular problem domain, a particular problem representation technique, and/or a particular solution technique."
: "The concept isn't new—special-purpose programming languages and all kinds of modeling/specification languages have always existed, but the term has become more popular due to the rise of domain-specific modeling (DSM)"
© C
op
yri
ght
20
10
O
beo
DSM ?
"Domain-specific modeling (DSM) is a software engineering methodology for designing and developing systems, such as computer software. It involves systematic use of a graphical domain-specific language (DSL) to represent the various facets of a system."
© C
op
yri
ght
20
10
O
beo
Et Martin, il en pense quoi ?
An important and useful distinction I make is between:
Internal DSLs are particular ways of using a host language to give the host language the feel of a particular language. (Ruby, Groovy, Scala ...)
AndExternal DSLs have their own custom syntax and you write a full parser to process them. There is a very strong tradition of doing this in the Unix community. Many XML configurations have ended up as external DSLs, although XML's syntax is badly suited to this purpose.
© C
op
yri
ght
20
10
O
beo
En résumé
Un Domain-Specific Language
Est un language Interne ou Externe
Peut-être Textuel ou Graphique
Définit le vocabulaire d'un domaine de connaissance particulier :
Par des mots
Par des représentations graphiques
Caractéristiques : simplicité, expressivité, explicite, ciblé, non ambigu
© C
op
yri
ght
20
10
O
beo
A quoi cela ressemble ?Notation :
Musicale :
Rubik's cube
Métier :
Calcul de polices d'assurances
Définition de règles métiers bancaires
Techniques :
SQL : SELECT * FROM GEEK WHERE JUG_MEMBER=1;
CSS : body { background-color: #CCCCCC; }
Regex : \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b
...
© C
op
yri
ght
20
10
O
beo
Pourquoi créer un DSL ?Pour :
Partager une métaphore commune entre un expert du domaine et un informaticien ex: spécifications fonctionnelles, ...
Permettre à un expert du domaine de participer à la construction de la logique métier d'une application ex: BPM, BRMS, ...
Exposer une API en tant que DSL et interpréter ce DSL. Plus expressif que du XML. Ex: API de configuration, ...
Générer du code Java ou autres pour gagner en productivité
© C
op
yri
ght
20
10
O
beo
Quel type de DSL créer ?DSL Interne :
Facile à créer
Exécutable via la langage hôte
Pas vraiment de sémantique (uniquement du sucre syntaxique)
Adhérent au langage hôte et limité par son expressivité
Uniquement textuel
Outillage IDE limité
© C
op
yri
ght
20
10
O
beo
Quel type de DSL créer ?DSL Externe :
Graphique (DSM) et/ou textuel
Facile à créer à condition d'utiliser les bons outils :
Xtext => textuel
Obeo Designer => graphique
Sémantique formelle
Outillage IDE industriel
© C
op
yri
ght
20
10
O
beo
Comment Eclipse Modeling peut-il m'aider ?
© C
op
yri
ght
20
10
O
beo
Un Eco-Système riche
© C
op
yri
ght
20
10
O
beo
Les DSL textuels
© C
op
yri
ght
20
10
O
beo
Un framework de développement de DSL textuel basé :
La plateforme Eclipse
EMF Eclipse Modeling Framework
ANTLR
© C
op
yri
ght
20
10
O
beo
Chercher l'intention ?
© C
op
yri
ght
20
10
O
beo
Une piste...
© C
op
yri
ght
20
10
O
beo
L'intention :Décrire l'entité métier JUG
Un JUG possède un nom
Un JUG est animé par un ou n JUG Leader
Cette entité est persistante en base de données
Conventions :
Une entité persistante est identifiée par un ID technique
Les identifiants techniques sont valués par une Séquence
© C
op
yri
ght
20
10
O
beo
Comment exprimer cette intention à l'aide d'un DSL textuel ?
© C
op
yri
ght
20
10
O
beo
Définition de la syntaxe textuelle de notre DSL avec TMF - Xtext
DEMO
© C
op
yri
ght
20
10
O
beo
Les DSL graphiques
© C
op
yri
ght
20
10
O
beo
Créer un DSL graphique : un DSM
Un environnement dédié
Paramétrage simples
Diagrammes hyper-ergonomiques
« Points de vue » pour l'analyse, l'architecte, …
Adaptable sur différents domaines
Basé sur Eclipse GMF
DEMO
© C
op
yri
ght
20
10
O
beo
Le système à modéliser
Les vues du système (les diagrammes)
(
Le point de vue
Du DSM au point de vue !Du DSM au point de vue !
Les vues du Système
● Analyse de performance● Analyse d'exigences● Fonction / Sous Fonction● Hardware / Software● DBA● Urbaniste des services
● Diagramme de blocs● Diagramme de composants● Diagramme de séquences● Tableur, Matrice
© C
op
yri
ght
20
10
O
beo
Quelques exemples...
© C
op
yri
ght
20
10
O
beo
Un modèle pour Tous
© C
op
yri
ght
20
10
O
beo
Exemples d'utilisation : http://obeonetwork.org
Communauté/Réseau de partenaires proposant des modules sur étagère : DSL/DSM/Générateurs JavaEE, Spring, ...
© C
op
yri
ght
20
10
O
beo
Autres exemples d'utilisation
© C
op
yri
ght
20
10
O
beo
© C
op
yri
ght
20
10
O
beo
Comment utilisez ces modèles ?
© C
op
yri
ght
20
10
O
beo
En Java ?
© C
op
yri
ght
20
10
O
beo
© C
op
yri
ght
20
10
O
beo
© C
op
yri
ght
20
10
O
beo
AcceleoGénération de code : implémentation du standard OMG MOF to Text Language
Licence EPL
Maintenu par Obeo
Un outil fait par des développeurs pour les développeurs !
Pragmatisme (génération incrémentale, …)
Outillage Eclipse (complétion, coloration syntaxique, ...)
DEMO
© C
op
yri
ght
20
10
O
beo
Des Questions ?
© C
op
yri
ght
20
10
O
beo
Sources / Liens
Wikipedia
http://en.wikipedia.org/wiki/Domain-specific_language
http://en.wikipedia.org/wiki/Domain-specific_modeling
http://www.martinfowler.com/bliki/DomainSpecificLanguage.html
http://www.obeo.fr/pages/obeo-designer/fr
http://www.obeonetwork.org
http://www.eclipse.org/modeling
http://www.eclipse.org/Xtext
http://www.eclipse.org/acceleo
http://www.slideshare.net/glaforge/domainspecific-languages-avec-groovy
http://blog.benois.fr/