27.03.2014 Views

SEKE 2012 Proceedings - Knowledge Systems Institute

SEKE 2012 Proceedings - Knowledge Systems Institute

SEKE 2012 Proceedings - Knowledge Systems Institute

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

engineer may also create other specialized entities having<br />

algorithms such as th e Gaussian filter, Proportional-Integral-<br />

Derivative (PID) controller, etc.<br />

A DSL may have multiple diagram kinds. When creating<br />

the language model, the domain engineer must know what kind<br />

of diagrams the DSL should have. The engineer should look at<br />

the Language Model in order to analyze if all entities can be<br />

addressed into only one diagram. If some entities cannot stay<br />

together, either because they are totally independent from each<br />

other or they could yield polluted diagrams, then the domain<br />

engineer should separate them into different diagrams. When<br />

separating entities into diagrams, there should be a balance<br />

between correlated entities and diagram pollution.<br />

Create code generation templates. In this activity, the<br />

domain engineer shall implement templates that are roughly<br />

fixed code with variation points. A domain framework could be<br />

created as well. It serves as a foundation for the generated code<br />

and provides artifacts that are common to all applications that<br />

can be generated.<br />

The process’ control flow may go back to the prior activity<br />

“Create Language Model”, because changes may be required in<br />

the language model depending on the code generation<br />

technology used. In Java Emitter Templates framework (JET),<br />

for example, a model is traversed as a graph. Commands that<br />

traverse instances of a pa rticular entity cannot guarantee the<br />

order they are processed. If the order is a must, the engineer<br />

should change the language model to assure it, for example, by<br />

adding an initial node that connects to the first instance and<br />

adding a relationship between instances that specifies the next<br />

to be processed. The process’ control flow may also go back to<br />

the activity “Identify domain abstractions”, because during<br />

template confection, it is common to n ote missing or even<br />

incorrect domain abstractions.<br />

Create language notation. The language notation is its<br />

concrete syntax, that is, how it visually represents its elements,<br />

relationships and properties. These representations must be<br />

meaningful to the users of the DSL. Choosing the most<br />

appropriate visual representations contributes significantly to<br />

the DSL success; however, this is beyond the scope of this<br />

paper.<br />

III. PROOF OF CONCEPT: A DSL FOR THE LEGO<br />

MINDSTORMS<br />

In this section, we describe how we conducted our process<br />

to create a DSL that generates code for LEGO Mindstorms.<br />

Figure 3. The generic language model<br />

Pick or build an application. Our mobile robot application<br />

has the following requirements: i) It must seek for opened<br />

doors along an aisle; ii) a sound alert shall be played when it<br />

finds one; and iii) when it reaches the end of the aisle, the robot<br />

should turn back and begin seeking again. We implemented our<br />

application using the LeJOS API [5].<br />

Identify domain abstractions. We extracted the domain<br />

abstractions and built the tree shown in Fig. 4. We divided the<br />

main objective into three nodes: “walk along aisle”, “detect<br />

open doors” and “sound alert if door is open”.<br />

After extracting the domain abstractions, we shall choose<br />

which ones will comprise the DSL. As mentioned before, one<br />

could pick abstractions from different levels—at the bottom<br />

lies the less abstracted ones and hence more flexible. We chose<br />

all from the “How to do” level but the “play sequence of<br />

tones”. Instead we chose its parent node. The next step is to<br />

categorize the chosen abstractions into concerns. We classified<br />

into Movement those that manipulate the motors, and into<br />

Detection those that use the sensors. The one that left was<br />

classified into the Communication concern since its goal is to<br />

notify someone about an opened door.<br />

Create language model. We created the language model<br />

shown in Fig. 5. There is the generic language model extended<br />

with our DSL entities, which are in bold. We also added<br />

properties to the generic entities, which are underlined.<br />

Create code generation templates. We used the Java<br />

Emitter Templates Framework (JET) to create the templates for<br />

code generation. The model built with the DSL is passed as an<br />

input to the templates and their tags traverse its elements to<br />

extract and process information, producing application’s code.<br />

We also created a domain framework that implements all the<br />

behaviors, for the generated code only instantiates and<br />

configures what is m odeled. The process of creating the<br />

domain framework reuses a significant part of the application<br />

developed in the first activity.<br />

Create language notation. In this activity, we created the<br />

notations of the DSL. To make it simple, choosing the best<br />

notations is out of the scope of our proof of concept.<br />

IV. RELATED WORK<br />

Günther et al. [9] show an agile and lightweight process for<br />

engineering DSLs embedded in dynamic languages. The<br />

process is divided into three phases: Domain Design, Language<br />

Design and Language Implementation. They also present<br />

several DSL-engineering patterns to be used in the last phase,<br />

which are strongly related to the following DSL engineering<br />

concerns: Language Modeling (what language constructs<br />

implement domain concepts), Language Integration (how to<br />

easily integrate the DSL with other components) and Language<br />

Purification (how to optimized e.g. readability).<br />

Robert et al. [10] define a lightweight process for designing<br />

UML profiles. The process has three activities: Problem<br />

description, Refinement restriction and Profile definition. Their<br />

resulting artifacts are respectively a Problem model, a Domain<br />

model and a Profile. There are two actors: the domain expert<br />

and the language expert. The former is responsible for the first<br />

activity, and the latter, for the last one; they both work in the<br />

497

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!