Archive for the ‘ DSLs ’ Category

Semantic typing in domain-specific languages

In domain-specific languages (DSL) concepts of the targeted problem-domain are introduced as language constructs. This is done in order to model using these concepts and abstract from specific technical solutions. However, a static typing of the DSL is useful, especially when it is used to calculate values. In DSLs the typesystem can be designed individually just as all the provided language constructs. For this reason, the data types shouldn’t be introduced because of technical differences but because of their semantics in the problem domain. Such semantic type systems and a static typing of a DSLs can prevent semantic errors during modeling by checking for type incompatibilities. This article discusses the idea of semantic typing and shows a concrete implementation in a DSL for creating user interfaces.

Continue reading

Designing Scalable Code Generators for very large Java Projects

Model-driven development is increasingly applied in large industrial projects. When java is used as the target language, some language details have to be considered that do not make any difference in conventional implementation. It is also necessary to take them into account when deciding between code generation and runtime interpretation. In order to make the generators scalable it is important to keep their execution times low. Furthermore, they need to be designed in such a way that changes to the source models result in localized and traceable effects in the generated code. This can be achieved by respecting some basic design rules during development of the code generators.

Continue reading

Improving Efficiency when Deriving Numerous Products from Software Product Lines Simultaneously

In-car infotainment systems must allow for product differentiation and the adaption to the needs of different markets. Product line approaches are applied because large numbers of different product variants need to be developed simultaneously. During development, updated versions of each projected product variant need to be derived from the product line assets repeatedly. Current build tools create each of the numerous product variants one after another. Accordingly, the creation process can take much time. This paper presents an approach to abbreviate this creation process based on the fact that multiple product variants created at once can have parts in common. To benefit from this optimization potential the workflow that creates an individual product variant is subdivided into multiple fragments. Whenever a set of such product variants needs to be created, an optimization algorithm then calculates an individual execution order of the fragments for this set. This order minimizes the total execution time by a systematic reuse of workflow fragment’s results for the creation of multiple different product variants.
Continue reading

Generate graphical Visualizations for textual DSLs

The advantage of using a textual notation for models is that no special editors are required to create and edit these models. Furthermore, the models can also be diffed and merged using standard tools. Such textual notations are particularly suitable for expert tools. Graphical notation, on the other hand, illustrate complex relations and are often easier to understand. The combination of both notations makes optimum use of their particular benefits.

In this post I will demonstrate how we can achieve this goal by enhancing the textual Xtext editors with graphical visualizations. The visualization will be shown in a view within the Eclipse IDE. Thus, we will use the SWT-based Zest toolkit for rendering.

Continue reading

URLs in Xtext

DSLs often include URLs. However, Ecore does not provide such a datatype by default. Also Xtext doesn’t provide a native rule for entering URLs as it is available for strings or integers.

In this post, I will explain all the nescessary steps to use URLs in Ecore models and in Xtext-based DSLs.
Continue reading

Generate Proxies for the WPF frontend

In the previous post we learned how a WPF user interface can be driven from a java application. The solution that was presented allows showing views, modifying controls’ properties, and starting or stopping animations. It is based on a set of generic functions that provide for the required functionality. Each one of these takes additional parameters to adress a specific view, control, animation, and property.

Assuming there is a control named mute in the view main. To set its boolean property checked to true, we need to call wpfFrontend.setWidgetPropertyBool("main", "mute", "checked", true). This call will fail, when the view, the control, or the property is not found for the given names, which can likely happen because of mispelling or after refactoring the user interface. Such errors cannot be detected by the Java compiler and will lead to runtime errors that are hard to detect. One can use proxies that encapsulate all the adressing in order to avoid these problems and offer a more convenient way to access the elements of the WPF frontend. Using proxies the modification of the control’s property can be done by a call to a setter, e.g. wpfFrontend.main.mute.setChecked(true).

This post shows how such Java proxies can be generated from a high-level description of the frontend elements.
Continue reading

Add Deprecated Annotations and Task Tags to your DSL

Some programming languages allow to discourage the usage of program element. For this purpose, Java provides the annotation @deprecated. It can be added to classes, fields and methods to express that the element should not be used any longer. There are many possible reasons, e.g., the element is unsafe or it has been superseded and may cease to exist in the future. When a deprecated element is used the compilers shows a warning. The Eclipse IDE marks all calls to deprecated methods and accesses to deprecated classes or fields.

Java developers using Eclipse JDT are probably also familiar to the task tags //XXX, //TODO and //FIXME. They offer a convenient way to mark positions in the source code that should be remembered for later reviews or adaptions. Eclipse lists all task tags found in the source code in a special view. By double clicking the entry in this view the IDE jumps to the corresponding position in the source code.

Both, the task tags and the deprecated-annotation are useful tools when creating Java programs in Eclipse. When working with large scale textual models, they can be beneficial, too. Xtext, however, does not provide such a feature out of the box. Though, it can be built with little effort by means of its validation framework.

This post describes how this can be done in such a way that it can be attached to different model elements with little effort.
Continue reading