1 Introduction
-
A more detailed commentary on the advantages and disadvantages of bespoke and generic modelling syntaxes in Sect. 2
-
A new YAML syntax flavour for Flexmi models with full feature parity with respect to the original XML flavour (Sect. 3.2)
-
The ability to set attribute values with the contents of external files (Sect. 3.6)
-
A systematic experimental evaluation of the impact of Flexmi’s fuzzy parsing and templating mechanism on verbosity and repetition (Sect. 4)
-
A systematic performance evaluation of Flexmi’s XML and YAML-based parsers
2 Background and motivation
2.1 Domain-specific modelling
2.2 Textual concrete syntaxes
2.2.1 Bespoke textual syntaxes
2.2.2 Generic textual syntaxes
Syntax type | Pros & Contras |
---|---|
Bespoke | + As customisable as needed |
+ Can be accommodated to end users | |
- Requires some initial cost | |
- Requires maintenance | |
Generic | + No upfront cost to use them |
- High rigidity due to exact matching | |
- Verbose | |
- Lacks the ability to reuse elements |
3 Flexmi
-
Intelligent and forgiving parsing that does not require exact lexical correspondence with type or feature names present in the metamodel (useful for conciseness)
-
A language-agnostic mechanism for defining and instantiating reusable model element templates (useful for conciseness and reuse)
3.1 Fuzzy parsing of elements
3.2 YAML/JSON syntax flavours
3.3 Containment slots
3.4 Non-containment references
3.5 Executable attributes and variables
3.6 Setting attribute values from file contents
3.7 Templates
template
> XML tag. For example, when designing one-person projects where all tasks take place in sequence, we can omit all the repetitive <effort
> elements that refer to the same person, and we can automate the calculation of the start date of each task by using a template, as shown in Listing 9.simpletask
is defined in lines 10–21. This template is used three times in lines 5–7. Based on its content (lines 11–20), each usage of this template generates a task element, which also contains an effort element. The start of the task and the person allocated to the effort are defined through executable attributes. The :start expression calculates the start time of a task by obtaining the task index in the list of all existing tasks, and then by accumulating the duration of all preceding tasks. The :person expression simply assigns the effort to the first Person element of the model (i.e. the only one available, Alice). As a side note, this is the first appearance of the <_\({>}{<}\)/_> special XML element, which is used to support Flexmi models that have more than one top-level elements (similarly to the <xmi:xmi
> tag in XMI).
3.7.1 Parametric templates
solo
) that can be used to define tasks carried out by a single person (lines 8–16). This template accepts a name and a person parameter (lines 9 and 10), which are used to name the task and to assign all the effort to the provided person, respectively. Parameters are provided as regular XML attributes when instantiating the template, as it happens in line 5 where Design and Alice are passed as name and person.
3.7.2 Dynamic templates and slots
content
> element of the longtask
template (lines 10–19). This template can be used to create tasks using years as duration unit, by providing a years value through a parameter (lines 5 and 11), which is translated to months in the EGL code (line 14). Also, Flexmi supports including a <:slot
> element in the content of templates, which specifies where any nested elements of the caller (e.g. the effort element of line 6) should be placed in the produced XML.
3.8 Importing other Flexmi Models and External Operations
?import other.flexmi?
> and <?include other.flexmi?
> processing instructions. The use of import creates a new EMF Resource for the other.flexmi
file, which is useful for referencing elements and for having the same Flexmi model imported by several models. On the other hand, include parses the contents of other.flexmi
as if they were embedded in the Flexmi model that contains the include processing instruction, just as the input command works for embedding LaTeX documents. This inclusion happens at the position where the processing instruction is placed, this means, we could include the contents of an external Flexmi file as children of a concrete XML element in the source file.people.flexmi
, which is depicted in Listing 12. This model can be imported from Flexmi models containing project details to reference the people that will carry out that project tasks, as shown in Listing 13. While we could also use the include instruction here, using import is preferred because if any project model also references another project, then the people.flexmi
will only be loaded once.
simpletask
template of Listing 9 (lines 12–17) is a one-liner that could be made more readable if divided into several lines. Listing 14 shows a pslOperations.e
ol
file doing just that in the getStartTime() operation, which is defined in a block of instructions and with the help of syntax highlighting. Then, Listing 15 shows how to use this EOL file from a Flexmi model: the eol processing instruction must be used (line 2), which allows changing the :start attribute to a simpler call to getStartTime() (line 7).
3.9 Tool support
acme.flexmi
file.
3.10 Limitations
4 Evaluation
4.1 Evaluation method
4.1.1 Ecore model dataset
4.1.2 Textual syntaxes generation
XMI term | Shortened as |
---|---|
EPackage | package |
EClass | class |
eStructuralFeatures (for EAttributes) | attr |
eStructuralFeatures (for EReferences) | ref |
eType (ETypedElement) | type |
upperBound (ETypedElement) | upper |
lowerBound (ETypedElement) | lower |
EAnnotation | annotation |
EOperation | op |
EDataType | type |
EEnum | enum |
EEnumLiteral | lit |
4.1.3 Measuring method
4.2 Results
4.2.1 Conciseness comparison
Syntax | #LOC |
---|---|
HUTN | 789,430 |
Plain Yaml Flexmi | 692,546 |
Templated YAML Flexmi | 536,044 |
XMI | 351,027 |
Plain XML Flexmi | 314,053 |
Templated XML Flexmi | 250,156 |
Emfatic | 167,521 |
4.2.2 Performance comparison
4.3 Threats to validity
Measurement | #Classes | #Attributes | #References |
---|---|---|---|
First Quartile | 11 | 11 | 11 |
Median | 20 | 19 | 19 |
Third Quartile | 39 | 35 | 43 |
Max | 945 | 7933 | 881 |
4.4 Discussion
-
Stability of the metamodel: in early iteration cycles Flexmi can be preferable to a custom syntax as it can eliminate the need to co-evolve a grammar as the metamodel evolves;
-
Expected return of investment: a custom textual syntax can provide usability benefits but also involves developing, maintaining, testing and distributing dedicated software (e.g. a grammar, scoping rules). While for large-scale projects (e.g. long-lived, many developers) the usability benefits of dedicated tooling can justify this additional effort, for smaller-scale projects a generic textual syntax like Flexmi can be preferable.