Transcript Slide 1

An Examination of DSLs for Concisely Representing
Model Traversals and Transformations
Jeff Gray
University of Alabama at Birmingham
Gábor Karsai
Vanderbilt University/ISIS
HICSS-36
This work is supported by the DARPA IXO, under the Program Composition for
Embedded Systems (PCES) program, Contract Number: F33615-00-C-1695
Support for this project was also provided by Boeing.
Overview

Three DSLs in two different applications


Applications: Tool integration and aspect-oriented
domain modeling (AODM)
Focus of DSLs:




Generation of complex data structures from high-level
specifications
Synthesis of iterative processes
Generation of API wrappers from high-level specs
Quantitative description of generated code
Tool Integration
Tool Integration
LRU
MM
LRU
VAR
FR
FDE
MSG
UNIT
OBS
ALR
Integrated Model Server (IMS)
AEFR
FMECA
ADO
Excel (csv)
ADO
RELEX
Text
IMS
ADVISE
CORBA
COM
GME
Browser
Tool Integration Framework (TIF)
New tools can access the IMS
directly through the CMI
Integrated
Tool
Legacy tools require a
bi-directional tool adapter
Legacy
Tool 1
Tool
Adapter
Legacy
Tool N
…
Tool
Adapter
IMS models can be viewed
in a web browser
Integrated
Model
Browser
ORB
CORBA
The CMI is specified in
CORBA IDL and defines
rules and data structures
for accessing the IMS
Common Model Interface
Naming Service
Semantic Translation
Meta-Model
Objects
IMS
Integrated Model
Database
MS Repository sits on top of an ODBC
database; currently Access or SQL Server
Tool Integration Framework (TIF)
New tools can access theFocus
IMS
directly through the CMI
Legacy tools require a
of thisbi-directional
portion oftool
theadapter
talk:
DSLs for representing
Integrated
tool models as stored in
Tool
the CMI
IMS models can be viewed
in a web browser
Legacyfor representing
Legacy model
…
DSLs
Integrated
Tool 1
Tool N
translation as traversal/visitor
Model
specifications
Browser
Tool
Adapter
Tool
Adapter
CORBAORB
The CMI is specified in
CORBA IDL and defines
rules and data structures
for accessing the IMS
Common Model Interface
Naming Service
Semantic Translation
Meta-Model
Objects
IMS
Integrated Model
Database
Pieces of the Translation

Structure of the models: Objects to be
traversed


Traversal sequences: How to traverse?


What are the desired paths for traversals?
Visitors: Actions to be taken


What are the possible paths for traversals?
What to do?
Phases of processing

Multiple passes over the structure
Tool Specification (Structure)
paradigm Foo;
model Top_Model {
...
part Component components;
}
model Component {
...
part Entity_1 ent_1;
part Entity_2 ent_2;
part Component subComponents;
rel Rel aRel
}
entity Entity_1 { ... }
entity Entity_2 { ... }
relation Rel {
Entity_1 src 1<->Entity_2 dst *;
}
Top_Model
Entity_1
1
*
Entity_2
Component
Generation of Data Structures
paradigm RELEX;
model RELEX_Model {
attr string Name;
part RELEX_Object objects;
part Failure_Mode failure_Modes;
rel RELEX_Failure_Mode rel_FM;
}
…
entity RELEX_Object {
attr string Name;
attr string Part_Number;
attr string User_Text;
attr string Reference;
attr double Failure_Rate;
}
entity Failure_Mode {
attr string Failure_Mode;
attr string Local_Effects;
attr string Next_Effects;
attr string End_Effects;
attr string Failure_Detection_Method;
attr long Mode_Severity_Code;
attr double Failure_Mode_Ratio;
attr double Failure_Effect_Probability;
attr double Failure_Rate;
}
relation RELEX_Failure_Mode {
RELEX_Object Owner 1 <->
Failure_Mode Failures *;
}
int RELEX_Model_M::get_objects(vector<RELEX_Object_E>& _res) {
int count = 0;
MetaEntity* type = MetaData::LookupEntity("RELEX","RELEX_Object");
vector<InstEntity*>::iterator itr;
vector<InstEntity*>* list = obj->parts();
for(itr = list->begin(); itr != list->end(); itr++) {
if((*itr)->type() == type) {
_res.push_back(RELEX_Object_E(*itr)); count++;
}
}
return count;
}
…
Structured Specification of Translators
(Traversal/Visitor)
visitor Visitor
{
at Component[...]
<<...>> traverse[...];
traversal Traversal using Visitor
{
from Top_Model ->[…]
<<...>> to { components[...] } <<...>>;
at Entity_1[...]
<<...>>;
from Component[...]
to { entity_1[...], entity_2[...],
subComponents[...], rel[...]
};
at Entity_2[...]
<<...>>;
at Rel[...]
traverse[...];
from Rel[...]
<<...>> to {src[...], dst[...] } <<...>>;
}
}
Generation of Traversal/Visitors
…
from Component[IMS::Component_M& parent]
to { failureModes[parent,fMap],
discrepancies[parent,dMap],
monitors[parent,mMap],
faultReports[parent],
subComponents[parent,pcMap],
fmMonitor[parent,fMap,mMap],
fmDiscrepancy[parent,fMap,dMap]
};
…
…
void Traversal_T::traverse(GME_4_0::Component_M& self,
IMS::Component_M& parent) {
vector<GME_4_0::FailureMode_E> _lst;
self.get_failureModes(_lst);
vector<GME_4_0::FailureMode_E>::iterator _itr;
for(_itr = _lst.begin(); _itr != _lst.end(); _itr++) {
GME_4_0::FailureMode_E arg=GME_4_0::FailureMode_E(*_itr);
vis->visit(arg,parent,fMap); }
vector<GME_4_0::Discrepancy_E> _lst;
self.get_discrepancies(_lst);
vector<GME_4_0::Discrepancy_E>::iterator _itr;
for(_itr = _lst.begin(); _itr != _lst.end(); _itr++) {
GME_4_0::Discrepancy_E arg=GME_4_0::Discrepancy_E(*_itr);
vis->visit(arg,parent,dMap); }
vector<GME_4_0::Monitor_E> _lst;
self.get_monitors(_lst);
vector<GME_4_0::Monitor_E>::iterator _itr;
for(_itr = _lst.begin(); _itr != _lst.end(); _itr++) {
GME_4_0::Monitor_E arg = GME_4_0::Monitor_E(*_itr);
vis->visit(arg,parent,mMap); }
vector<GME_4_0::Fault_Report_E> _lst;
self.get_faultReports(_lst);
vector<GME_4_0::Fault_Report_E>::iterator _itr;
for(_itr = _lst.begin(); _itr != _lst.end(); _itr++) {
GME_4_0::Fault_Report_E arg=GME_4_0::Fault_Report_E(*_itr);
vis->visit(arg,parent); }
vector<GME_4_0::Component_M> _lst;
self.get_subComponents(_lst);
vector<GME_4_0::Component_M>::iterator _itr;
for(_itr = _lst.begin(); _itr != _lst.end(); _itr++) {
GME_4_0::Component_M arg = GME_4_0::Component_M(*_itr);
vis->visit(arg,parent,pcMap); }
vector<GME_4_0::FMMonitor_R> _lst;
self.get_fmMonitor(_lst);
vector<GME_4_0::FMMonitor_R>::iterator _itr;
for(_itr = _lst.begin(); _itr != _lst.end(); _itr++) {
GME_4_0::FMMonitor_R arg = GME_4_0::FMMonitor_R(*_itr);
vis->visit(arg,parent,fMap,mMap); }
vector<GME_4_0::FMDiscrepancy_R> _lst;
self.get_fmDiscrepancy(_lst);
vector<GME_4_0::FMDiscrepancy_R>::iterator _itr;
for(_itr = _lst.begin(); _itr != _lst.end(); _itr++) {
GME_4_0::FMDiscrepancy_R arg=GME_4_0::FMDiscrepancy_R(*_itr);
vis->visit(arg,parent,fMap,dMap); }
}
…
Achieved Goals - Tool Integration



Using a DSL, the underlying CORBA data
structures and service calls that are needed
to perform the model integration are hidden.
Using a DSL, the often tedious and repetitive
code fragments that are needed for iteration
and transformation can be more
concisely/intuitively specified.
Separation of concerns:

Cleaner solution by separating semantic
(translator) and syntactic (adapter) issues
Aspect-Oriented
Domain Modeling
Please see October 2001 issue of
Communications of the ACM
Model-Integrated Computing (MIC) with the
Generic Modeling Environment (GME)
• Generic Modeling Environment (GME) is a
domain-specific modeling tool
• Grew out of over 14 years of research on
computer-based systems in aerospace,
instrumentation, manufacturing and robotics.
• It can be utilized in many different domains
by providing a meta-level paradigm
description. Paradigm describes all of the
entities of the domain, as well as valid
relationships
• A modeler first loads the domain paradigm
and then constructs new models in that
domain
Please see November 2001 issue of IEEE Computer
Available for download at http://www.isis.vanderbilt.edu
Difficulties in Managing Constraints
4
Multiple Levels
of Hierarchy
A
Replicated
Structures
3
B
1
c
2
d
F
e
3'
B
1'
Context
Sensitive
Change
Maintenance???
c
2'
d
B
e
1''
c
2''
d
e
4
Process of Using a Model Weaver
GME
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project SYSTEM "mga.dtd">
<project guid="{00000000-0000-0000-0000-00 000000 0000}" cdate="Thu Nov 30 14:15:40 2000" mdate="Thu Nov 30 14:15:40 2000" metaguid="{00000000-0000-0000-0000-00 000000 0000}" metaname="PCES">
<name>bit1</name>
<comment></comment>
<author></author>
<folder id="id-006a-00000001" kind="RootFolder">
<name>bit1</name>
<folder id="id-006a-00000002" kind="Structural">
<name>Structural</name>
<model id="id-0065-00000001" kind="ProcessingCompound">
<name>ProcessingCompound</name>
<attribute kind="Description" status="meta">
<value></value>
</attribute>
<atom id="id-0066-00000007" kind="Attribute" role="Attrib">
<name>GatesPerBit</name>
<regnode name="PartRegs">
<value></value>
<regnode name="StructuralAspect">
<value></value>
<regnode name="Position" isopaque="y es">
<value>37,153</value>
</regnode>
</regnode>
</regnode>
<attribute kind="Value" status="meta">
<value></value>
</attribute>
</atom>
<atom id="id-0066-00000006" kind="Attribute" role="Attrib">
<name>NomBits</name>
<regnode name="PartRegs">
<value></value>
<regnode name="StructuralAspect">
<value></value>
<regnode name="Position" isopaque="y es">
<value>205,76</value>
</regnode>
</regnode>
</regnode>
<attribute kind="Value" status="meta">
<value></value>
</attribute>
</atom>
<atom id="id-0066-00000005" kind="Attribute" role="Attrib">
<name>MaxBits</name>
<regnode name="PartRegs">
<value></value>
<regnode name="StructuralAspect">
<value></value>
<regnode name="Position" isopaque="y es">
<value>128,76</value>
</regnode>
</regnode>
</regnode>
Enhanced
FOO.XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project SYSTEM "mga.dtd">
FOO.XML
<project guid="{00000000-0000-0000-0000-00 000000 0000}" cdate="Thu Nov 30 14:15:40 2000" mdate="Thu Nov 30 14:15:40 2000" metaguid="{00000000-0000-0000-0000-00 000000 0000}" metaname="PCES">
<name>bit1</name>
<comment></comment>
<author></author>
<folder id="id-006a-00000001" kind="RootFolder">
<name>bit1</name>
<folder id="id-006a-00000002" kind="Structural">
<name>Structural</name>
<model id="id-0065-00000001" kind="ProcessingCompound">
<name>ProcessingCompound</name>
<attribute kind="Description" status="meta">
<value></value>
</attribute>
<atom id="id-0066-00000007" kind="Attribute" role="Attrib">
<name>GatesPerBit</name>
<regnode name="PartRegs">
<value></value>
<regnode name="StructuralAspect">
<value></value>
<regnode name="Position" isopaque="y es">
<value>37,153</value>
</regnode>
</regnode>
</regnode>
<attribute kind="Value" status="meta">
<value></value>
</attribute>
</atom>
<atom id="id-0066-00000006" kind="Attribute" role="Attrib">
<name>NomBits</name>
<regnode name="PartRegs">
<value></value>
<regnode name="StructuralAspect">
<value></value>
<regnode name="Position" isopaque="y es">
<value>205,76</value>
</regnode>
</regnode>
</regnode>
<attribute kind="Value" status="meta">
<value></value>
</attribute>
</atom>
<atom id="id-0066-00000005" kind="Attribute" role="Attrib">
<name>MaxBits</name>
<regnode name="PartRegs">
<value></value>
<regnode name="StructuralAspect">
<value></value>
<regnode name="Position" isopaque="y es">
<value>128,76</value>
</regnode>
</regnode>
</regnode>
Domain-Specific
Weaver
Specification
constraint FOOB2
{
// apply a specific constraint to “B2” only
in Structural models("ProcessingCompound")->
select(p | p.name() == "B2")->PowerStrategy (1, 100);
}
constraint FOOBStar
{
// apply a specific constraint to all nodes beginning with “B” - use
wildcard
in Structural models("ProcessingCompound")->
select(p | p.name() == "B*")->PowerStrategy (1, 100);
}
Aspects
Quantification Over Base Code
(AOP)
Weavers ‘instrument’ code with advice

Comp1
package org. apac he.to mcat. sessi on;
void va lidat e() {
// i f we have an i nacti ve in terv al, c heck to se e if
// w e've exce eded it
import org.a pach e.tom cat.c ore.* ;
import org.a pach e.tom cat.u til.S tring Mana ger;
import java. io.* ;
import java. net. *;
import java. util .*;
import javax .ser vlet. *;
import javax .ser vlet. http. *;
if ( inac tiveI nterv al != -1) {
int thisI nterv al =
(int) (Syst em.cu rrent Time Milli s() - last Acces sed) / 10 00;
if ( thisI nterv al > inact iveI nterv al) {
inval idate ();
/**
* Core impl emen tatio n of a ser ver s essi on
*
* @aut hor J ames Dunc an Da vidso n [du ncan @eng. sun.c om]
* @aut hor J ames Todd [gon zo@en g.sun .com ]
*/
Serve rSess ionMa nager ssm =
S erver Sessi onMan ager .getM anage r();
ssm.r emove Sessi on(th is);
}
}
public class Ser verSe ssion {
}
pri vate Stri ngMan ager sm =
Stri ngMa nager .getM anage r("or g.ap ache. tomca t.ses sion" );
pri vate Hash table valu es = new H asht able( );
pri vate Hash table appS essio ns = new Hasht able( );
pri vate Stri ng id ;
pri vate long crea tionT ime = Syst em.c urren tTime Milli s();;
pri vate long this Acces sTime = cr eati onTim e;
pri vate long last Acces sed = crea tion Time;
pri vate int inact iveIn terva l = - 1;
syn chron ized void inva lidat e() {
Enum erat ion e num = appS essio ns.k eys() ;
Ser verSe ssio n(Str ing i d) {
this .id = id;
}
}
pub lic v oid putVa lue(S tring name , Ob ject value ) {
if ( name == n ull) {
Stri ng ms g = s m.get Strin g("s erver Sessi on.va lue.i ae") ;
whil e (e num.h asMor eElem ents( )) {
Obje ct ke y = e num.n extEl emen t();
Appl icati onSes sion appSe ssio n =
(Appl icati onSes sion) appS essio ns.ge t(key );
appS essio n.inv alida te();
}
pub lic S trin g get Id() {
retu rn i d;
}
thro w new Ille galAr gumen tExc eptio n(msg );
}
pub lic l ong getCr eatio nTime () {
retu rn c reati onTim e;
}
remo veVa lue(n ame); // remov e an y exi sting bind ing
valu es.p ut(na me, v alue) ;
}
pub lic l ong getLa stAcc essed Time( ) {
retu rn l astAc cesse d;
}
pub lic O bjec t get Value (Stri ng na me) {
if ( name == n ull) {
Stri ng ms g = s m.get Strin g("s erver Sessi on.va lue.i ae") ;
pub lic A ppli catio nSess ion g etApp lica tionS essio n(Con text cont ext,
bool ean creat e) {
Appl icat ionSe ssion appS essio n =
(App licat ionSe ssion )appS essi ons.g et(co ntext );
thro w new Ille galAr gumen tExc eptio n(msg );
}
retu rn v alues .get( name) ;
if ( appS essio n == null && cr eate ) {
}
// X XX
// s ync t o ens ure v alid?
pub lic E nume ratio n get Value Names () {
retu rn v alues .keys ();
}
appS essio n = n ew Ap plica tion Sessi on(id , thi s, co ntex t);
appS essio ns.pu t(con text, app Sessi on);
pub lic v oid remov eValu e(Str ing n ame) {
valu es.r emove (name );
}
}
// X XX
// m ake sure that we ha ven't gon e ove r the end of ou r
// i nact ive i nterv al -- if s o, i nvali date and c reate
// a new appS essio n
pub lic v oid setMa xInac tiveI nterv al(i nt in terva l) {
inac tive Inter val = inte rval;
}
retu rn a ppSes sion;
pub lic i nt g etMax Inact iveIn terva l() {
retu rn i nacti veInt erval ;
}
}
voi d rem oveA pplic ation Sessi on(Co ntex t con text) {
appS essi ons.r emove (cont ext);
}
// XXX
// sync' d fo r saf ty -- no o ther thre ad sh ould be ge tting som ethin g
// from this whil e we are r eapin g. T his i sn't the m ost o ptim al
// solut ion for t his, but w e'll dete rmine some thing else lat er.
/**
* Calle d by cont ext w hen r eques t co mes i n so that acces ses and
* inact ivit ies c an be deal t wit h ac cordi ngly.
*/
after(Object o) throwing (Error e): pubIntf(o) {
log.write(o, e);
…
}
syn chron ized void reap () {
Enum erat ion e num = appS essio ns.k eys() ;
voi d acc esse d() {
// s et l ast a ccess ed to this Acce ssTim e as it wi ll be lef t ove r
// f rom the p revio us ac cess
whil e (e num.h asMor eElem ents( )) {
Obje ct ke y = e num.n extEl emen t();
Appl icati onSes sion appSe ssio n =
(Appl icati onSes sion) appS essio ns.ge t(key );
last Acce ssed = thi sAcce ssTim e;
this Acce ssTim e = S ystem .curr entT imeMi llis( );
appS essio n.val idate ();
}
}
}
}
voi d val idat e()
Comp2
package org. apac he.to mcat. sessi on;
import org.a pach e.tom cat.u til.* ;
import org.a pach e.tom cat.c ore.* ;
import java. io.* ;
import java. net. *;
import java. util .*;
import javax .ser vlet. http. *;
// XXX
// sync' d fo r saf ty -- no o ther thre ad sh ould be ge tting som ethin g
// from this whil e we are r eapin g. T his i sn't the m ost o ptim al
// solut ion for t his, but w e'll dete rmine some thing else lat er.
syn chron ized void reap () {
Enum erat ion e num = sess ions. keys ();
whil e (e num.h asMor eElem ents( )) {
Obje ct ke y = e num.n extEl emen t();
Serv erSes sion sessi on = (Ser verSe ssion )sess ions. get( key);
/**
*
* @aut hor J ames Dunc an Da vidso n [du ncan @eng. sun.c om]
* @aut hor J ason Hunt er [j ch@en g.sun .com ]
* @aut hor J ames Todd [gon zo@en g.sun .com ]
*/
sess ion.r eap() ;
sess ion.v alida te();
}
}
public class Ser verSe ssion Manag er im plem ents Sessi onMan ager {
syn chron ized void remo veSes sion( Serv erSes sion sessi on) {
Stri ng i d = s essio n.get Id();
pri vate Stri ngMan ager sm =
Stri ngMa nager .getM anage r("or g.ap ache. tomca t.ses sion" );
pri vate stat ic Se rverS essio nMana ger manag er; / / = n ew Se rver Sessi onMan ager( );
sess ion. inval idate ();
sess ions .remo ve(id );
}
pro tecte d in t ina ctive Inter val = -1;
pub lic v oid remov eSess ions( Conte xt c ontex t) {
Enum erat ion e num = sess ions. keys ();
sta tic {
mana ger = new Serv erSes sionM anag er();
}
whil e (e num.h asMor eElem ents( )) {
Obje ct ke y = e num.n extEl emen t();
Serv erSes sion sessi on = (Ser verSe ssion )sess ions. get( key);
Appl icati onSes sion appSe ssio n =
sessi on.ge tAppl icati onSe ssion (cont ext, false );
pub lic s tati c Ser verSe ssion Manag er g etMan ager( ) {
retu rn m anage r;
}
pri vate Hash table sess ions = new Has htabl e();
pri vate Reap er re aper;
if ( appSe ssion != n ull) {
appSe ssion .inva lidat e();
}
pri vate Serv erSes sionM anage r() {
reap er = Reap er.ge tReap er();
reap er.s etSer verSe ssion Manag er(t his);
reap er.s tart( );
}
}
}
/**
* Used by c ontex t to confi gure the sessi on ma nager 's in acti vity timeo ut.
*
* The S essi onMan ager may h ave s ome defau lt se ssion time out , the
* Conte xt o n the othe r han d has it' s tim eout set b y the dep loyme nt
* descr ipto r (we b.xml ). Th is me thod lets the Conte xt co nfor gure the
* sessi on m anage r acc ordin g to this valu e.
*
* @para m mi nutes The sessi on in acti vity timeo ut in minu tes.
*/
pub lic v oid setSe ssion TimeO ut(in t mi nutes ) {
if(- 1 != minu tes) {
// T he ma nager work s wit h se conds ...
inac tiveI nterv al = (minu tes * 60) ;
}
}
pub lic v oid acces sed( Conte xt ct x, R eques t req , Str ing i d ) {
Appl icat ionSe ssion apS= (Appl icat ionSe ssion )find Sessi on( ctx, id);
if( apS= =null ) ret urn;
Serv erSe ssion serv S=apS .getS erve rSess ion() ;
serv S.ac cesse d();
apS. acce ssed( );
// c ache it - no n eed t o com pute it a gain
req. setS essio n( ap S );
}
pub lic H ttpS essio n cre ateSe ssion (Con text ctx) {
Stri ng s essio nId = Sess ionId Gene rator .gene rateI d();
Serv erSe ssion sess ion = new Serv erSes sion( sessi onId) ;
sess ions .put( sessi onId, sess ion) ;
if(- 1 != inac tiveI nterv al) {
sess ion. setMa xInac tiveI nterv al(i nacti veInt erval );
}
retu rn s essio n.get Appli catio nSes sion( ctx, true );
}
pub lic H ttpS essio n fin dSess ion(C onte xt ct x, St ring id) {
Serv erSe ssion sSes sion= (Serv erSe ssion )sess ions. get(i d);
if(s Sess ion== null) retu rn nu ll;
retu rn s Sessi on.ge tAppl icati onSe ssion (ctx, fals e);
}
}
pointcut pubIntf(Object o):
call(public * com.borland.*.*(..)) &&
target(o);
Quantification Over a Domain Model
(AODM)

Apply AO Weaving concepts to Model-based
systems


Weavers ‘Decorate’ Models with attributes &
constraints
Weavers compose new model constructs
Strategy1
Strategy2
Strategy3
StrategyN
…
select(p | p.name() == “Model*” &&
p.kind() == “StateFlow”)->Strategy3();
…
The Metaweaver Framework
XML
Specification
Strategies (C++)
Aspects
(Model Hierarchy)
Strategy Specifications
strategy ApplyConstraint(constraintName : string, expression : string)
{
addAtom("OCLConstraint", "Constraint", constraintName).addAttribute("Expression", expression);
}
Strategy
Code
Generator
strategy RemoveConstraint(constraintName : string)
{
findAtom(constraintName).removeChild();
}
strategy ReplaceConstraint(constraintName : string, expression : string)
{
RemoveConstraint(constraintName);
ApplyConstraint(constraintName, expression);
}
Embedded Constraint Language
Included OCL Operators
Arithmetic Operators
Logical Operators
Collection Operator
Property Operator
Standard OCL
Collection Operators
+, -, *, /, =, <, >, <=, >=, <>
and, or, xor, not, implies,
if/then/else
->
.
collection->size() : integer
collection->forAll( x | f(x) ) : Boolean
collection->select( x | f(x) ) : collection
collection->exists( x | f(x) ) : Boolean
Embedded Constraint Language (ECL)



Traditional OCL has been strictly a declarative query
language
New uses require an imperative procedural style
Addition of side effects into model

Examples:





addAtom(…), findAtom(…)
addAttribute(…), findAttribute(…)
removeNode(…)
Support for recursion
Chaining of strategies (procedure calls)

Inlined C++ code
Generation of ECL
…
components.models("")->select(c |c.id() == refID)->DetermineLaziness();
…
CComPtr<IXMLDOMNodeList> mods=XMLParser::models(components,"");
nodeTypeVector selectVec1 = XMLParser::ConvertDomList(mods);
nodeTypeVector selectVecTrue1 = new std::vector<nodeType>;
vector<nodeType>::iterator itrSelect1;
for(itrSelect1 = selectVec1->begin(); itrSelect1 != selectVec1->end();
itrSelect1++) {
nodeType selectNode1 = (*itrSelect1);
nodeType c; c = selectNode1;
CComBSTR id0 = XMLParser::id(c);
ClData varforward1(id0);
ClData varforward2(refID);
bool varforward3 = varforward1 == varforward2;
if(varforward3)
selectVecTrue1->push_back(*itrSelect1);
}
vector<nodeType>::iterator itrCollCall1;
for(itrCollCall1 = selectVecTrue1->begin(); itrCollCall1 != selectVecTrue1->end();
itrCollCall1++)
DetermineLaziness::apply(…);
Achieved Goals - AODM


Using a DSL, the modeler is shielded from
the details of the core XML Document Object
Model (DOM) API calls.
Using a DSL, the specification of the
navigation within the domain models (while
performing transformations) is raised to a
higher level of abstraction
Analysis of Generated Code
MSF to Generated Code
Advise
Relex
FMECA
AEFR
GME
Lines of Code
MSF: 33
C++: 506
Ratio: 1::15.33
MSF: 34
C++: 538
Ratio: 1::15.82
MSF: 44
C++: 802
Ratio: 1::18.22
MSF: 49
C++: 639
Ratio: 1::13.04
MSF: 58
C++: 922
Ratio: 1::15.89
Bytes of Code
MSF: 761b
C++: 14.79k
Ratio: 1::19.44
MSF: 819b
C++: 17.54k
Ratio: 1::21.42
MSF: 1.26k
C++: 27.32k
Ratio: 1::21.68
MSF: 870b
C++: 21.42k
Ratio: 1::24.62
MSF: 1.19k
C++: 28.71k
Ratio: 1::24.13
TVL to Generated Code
Lines of Code
Advise2IMS
TVL: 155
C++: 355
Ratio: 1::2.29
Relex2IMS
TVL: 351
C++: 523
Ratio: 1::1.49
FMECA2IMS
TVL: 248
C++: 435
Ratio: 1::1.75
AEFR2IMS
TVL: 192
C++: 497
Ratio: 1::2.59
GME2IMS
TVL: 251
C++: 523
Ratio: 1::2.08
Bytes of Code
TVL: 4.03k
C++: 8.78k
Ratio: 1::2.18
TVL: 10.15k
C++: 17.54k
Ratio: 1::1.73
TVL: 7.85k
C++: 12.10k
Ratio: 1::1.54
TVL: 6.49k
C++: 13.39k
Ratio: 1::2.06
TVL: 7.22k
C++: 14.27k
Ratio: 1::1.98
ECL to Generated Code
Lines of
Code
Power
ECL: 43
Distribution C++: 140
Ratio:
1::3.25
Processor
ECL: 39
Assignment C++: 137
Ratio:
1::3.50
Eager/Lazy ECL: 85
C++: 230
Ratio:
1::2.71
Exhaustive ECL: 70
State
C++: 184
Transition
Ratio:
1::2.62
State
ECL: 128
Generation C++: 242
Ratio:
1::1.89
Bytes of Code
ECL: 859b
C++: 3.08k
Ratio: 1::3.50
ECL: 954b
C++: 3.28k
Ratio: 1::3.44
ECL: 2.03k
C++: 6.24k
Ratio: 1::3.07
ECL: 1.92k
C++: 5.14k
Ratio: 1::2.68
ECL: 3.42k
C++: 6.76k
Ratio: 1::1.98
Concluding RemarksBenefits of DSL use in these Two Projects



The tedious and mundane parts of writing a program
are automated in the translation from the DSL to a
traditional programming language.
Repetitive code sequences are generated
automatically instead of the error-prone manual cutand-paste method. The generation of such tedious
code also has advantages in the maintenance phase
of a project’s lifecycle.
Solutions can be constructed quickly because the
programmer can more easily focus on the key
abstractions. A DSL hides the underlying details of the
solution space as implemented in a traditional
programming language.
Concluding Quotes



Niklaus Wirth: We must recognize the strong and undeniable
influence that our language exerts on our ways of thinking and, in
fact, delimits the abstract space in which we can formulate – give
form to – our thoughts.
George Polya: An important step in solving a problem is to choose
the notation. It should be done carefully. The time we spend now
on choosing the notation may be well repaid by the time we save
later avoiding hesitation and confusion. Moreover, choosing the
notation carefully, we have to think sharply of the elements of the
problem which must be denoted. Thus, choosing a suitable
notation may contribute essentially to understanding the problem.
Ted Biggerstaff: The first order term in the success equation of
reuse is the amount of domain-specific content and the second
order term is the specific technology chosen in which to represent
that content.
Additional Slides
Evaluating Tool Integration Solutions




How much time and effort does it cost to
integrate a new tool?
How scalable is the integration approach?
How much expert knowledge is needed to
realize an integration solution?
What is the coupling between the individual
tools and the integration technology?
Development Effort

Translators can be written within a few man-days


Tool Adapter development depends on:




Average translator was 225 lines of traversal/visitor code
Complexity of tool
Complexity of the tool’s data access mechanism
(e.g., ADO, COM, comma separated values)
Developer experience with previous Tool Adapters
Our average development time for a bi-directional
Tool Adapter is about 10 person-weeks
Lessons Learned


Successful integration of 5 tools
Separation of concerns:


Cleaner solution by separating semantic and syntactic
issues
Framework approach using software generators



infrastructural elements
tool-specific translators (componentized)
traversal/visitor specification language