The DEx CD Lite language
Version 1.0
April 3
rd, 2014
Internal report
Marita Breuer, Robert Eikermann, Timo Greifenberg, Katrin Hölldobler, Andreas Horst, Markus Look, Steffi Kaiser, Dimitri Plotnikov, Alex Roth, Bernhard Rumpe, Galina Volkova
Software Engineering RWTH Aachen
Germany
Explanation and Introduction
DEX is a generator framework that basically generates a complete, running system from a single class diagram. While the DEX generator framework is capable of doing many more things, we also use it for the “Generative Software Development” lecture at RWTH Aachen. In this document we describe the core features of DEX that are mapped to the running program. These core features are defined as a simplified version of UML’s class diagrams, that we call “CD lite”.
For more details please see
http://www.monticore.de/dex
DEX is a subproject of MontiCore – the DSL language workbench developed at RWTH Aachen.
The rest of this document contains two sections: 1. The human readable grammar of CD lite.
2. The list of context conditions that apply to CD lite.
This grammar is meant to understand the context free syntax of CD lite. It is not meant for parsing, and not for understanding the abstract syntax. Please note that in comparison to the UML/P class diagrams, the nonterminals have been renamed (by removing the “CD” prefix) and sometimes substructures have been removed.
The context conditions come with the error code (that is also shown, when violated), and good and bad examples as well as with a reference to the context condition in [Sch12].
Literature
1. [Rum12] B. Rumpe. Agile Modellierung mit UML : Codegenerierung, Testfälle, Refactoring. 2nd Edition, Springer Berlin, June 2012.
2. [Wei12] I. Weisemöller. Generierung domänenspezifischer Transformationssprachen. Shaker Verlag, ISBN 978-3-8440-1191-3. Aachener Informatik-Berichte, Software Engineering, Band 12. 2012.
3. [Sch12] M. Schindler. Eine Werkzeuginfrastruktur zur agilen Entwicklung mit der UML⁄P. Shaker Verlag, ISBN 978-3-8440-0864-7. Aachener Informatik-Berichte, Software Engineering Band 11. 2012.
4. [HRR12] A. Haber, J. O. Ringert, B. Rumpe. MontiArc - Architectural Modeling of Interactive Distributed and Cyber-Physical Systems. RWTH Aachen University, Technical Report. AIB-2012-03. February 2012.
5. [MRR11e] S. Maoz, J. O. Ringert, B. Rumpe. CD2Alloy: Class Diagrams Analysis Using Alloy Revisited. In: Model Driven Engineering Languages and Systems (MODELS 2011), Wellington, New Zealand. pp. 592-607, LNCS 6981, 2011.
6. [Rum11] B. Rumpe. Modellierung mit UML. 2nd Edition, Springer Berlin, September 2011.
7. [KRV10] H. Krahn, B. Rumpe, S. Völkel. MontiCore: a Framework for Compositional Development of Domain Specific Languages. In: International Journal on Software Tools for Technology Transfer (STTT), Volume 12, Issue 5, pp. 353-372, September 2010. 8. [KBV06] H. Krahn, B. Rumpe, S. Völkel. Roles in Software Development using Domain
Specific Modeling Languages. In: Proceedings of the 6th OOPSLA Workshop on Domain-Specific Modeling (DSM' 06), Portland, Oregon USA. Technical Report TR-37, Jyväskylä University, Finland, 2007
9. [GKR+06a] H. Grönniger, H. Krahn, B. Rumpe, M. Schindler, S. Völkel. MontiCore 1.0 - Ein Framework zur Erstellung und Verarbeitung domänenspezifischer Sprachen. Informatik-Bericht 2006-04. Technische Universität Braunschweig, Carl-Friedrich-Gauss-Fakultät für Mathematik und Informatik, 2006.
10. [GKR+06b] H. Grönniger, H. Krahn, B. Rumpe, M. Schindler. Integration von Modellen in einen codebasierten Softwareentwicklungsprozess. In: Proceedings der Modellierung 2006. 22.-24. März 2006, Innsbruck. GI-Edition - Lecture Notes in Informatics, LNI P-82, ISBN 3-88579-176-5, 2006.
11. [Rum04c] B. Rumpe. Agile Modeling with the UML. Ed.: M. Wirsing, A. Knapp, S. Balsamo. In: Radical Innovations of Software and Systems Engineering in the Future. 9th International Workshop, RISSEF 2002. Venice, Italy, October 2002. LNCS 2941. Springer Verlag 2004.
12. [Rum03] B. Rumpe. Model-Based Testing of Object-Oriented Systems. In: Formal Methods for Components and Objects. F. de Boer, M.Bonsangue, S. Graf, W.-P. de Roever (eds.) International Symposium, FMCO 2002. Leiden, November 2002, Revised Lectures. LNCS 2852, Springer Publisher, 2003
13. [Rum02] Bernhard Rumpe. Executable Modeling with UML. A Vision or a Nightmare? In: Issues & Trends of Information Technology Management in Contemporary Associations, Seattle. Idea Group Publishing, Hershey, London, pp. 697-701. 2002.
Grammar for textual class diagrams
CDDefinition ="classdiagram" Name "{"
(CDClass | CDInterface | CDEnum | CDAssociation)* "}"
CDClass =
"abstract"? "class" Name
("extends" ReferenceType ("," ReferenceType)*)? ("implements" ReferenceType ("," ReferenceType)*)? (CDClassBody | ";")
CDClassBody =
"{" CDAttribute* "}" CDAttribute =
"/"? Type Name ("=" Value)? ";"
CDInterface =
"interface" Name
("extends" ReferenceType ("," ReferenceType)*)? ";" CDEnum = "enum" Name (CDEnumBody | ";") CDEnumBody = "{" (CDEnumConstant ("," CDEnumConstant)* ";")? "}" CDEnumConstant = Name CDAssociation =
"<<ordered>>"? "association" "/"? Name? "<<ordered>>"? Cardinality? QualifiedName CDQualifier? RoleName? ( "->" | "<-" | "<->" | "--" )
RoleName? CDQualifier? QualifiedName Cardinality? "<<ordered>>"? ";"
Cardinality =
"[" ("*" | Int | Int ".." Int | Int ".." "*") "]"; CDQualifier = "[" Name "]"
RoleName = "(" Name ")"
In natural language:
The DEx CD Lite language allows you to model: Examples:
Classes,
Abstract classes, Interfaces, Enumerations
class SomeClass;
abstract class SomeAbstractClass; interface SomeInterface;
enum SomeEnum; Inheritance
• with non-abstract superclasses • with abstract superclasses
class SomeClass;
abstract class SomeAbstractClass; class SomeSubClassA extends SomeClass;
class SomeSubClassB extends SomeAbstractClass;
Interface implementation interface SomeInterface;
class SomeClass implements SomeInterface;
Extension of interfaces interface SomeInterface;
interface SomeInterfaceA extends SomeInterface;
Attributes with type: • primitive data type • String
• Class in the CD model • Interface in the CD model • Date
• Wrapper
• List<Wrapper of primitive data type> • List<String> class SomeClassA; interface SomeInterface; class SomeClassC { int i; boolean b; String s; SomeClassA sca; SomeInterface si; Date d;
Integer i2; Boolean b2; List<Integer>;
List<String>; }
Associations
• From classes, abstract classes, interfaces (NOT: enums, external java classes)
• To classes, abstract classes, interfaces, enums (NOT: external java classes)
• With multiplicities: [0,1], [1], [*]
• With navigation directions: ->, <-, --, <--> • With association and role names • Qualified associations:
o With key: attribute of the opposite class o With stereotype <<ordered>>
class SomeClass;
abstract class SomeAbstractClass; interface SomeInterface;
association someAssociationA [*] SomeClass (roleA) <-> (roleB) SomeAbstractClass [1]
association someAssociationB SomeAbstractClass -- SomeInterface
Modifiers
• abstract (for classes) • derived for attributes • derived for associations
class A; class B;
abstract class SomeAbstractClass; /int someNumber
association /someAssociation A -- B
Context conditions for textual class diagrams
ErrorCodes [Sch12] Please ensure that… Wrong example Correct example
NAMING CONVENTIONS
0xA0143 All-1-14 The name of your diagram is unique in the package (this condition includes diagrams of different types).
0xU0454, 0xU0440, 0xU0441, 0xU0484, 0xU0485, 0xU0486.
CD-1-50 Attribute names / association and role names start with a lowercase character.
0xU0436 CD-1-46 A class which references another one by an association or a role name does NOT contain an attribute with this name. (This context condition 1. includes attributes of possible super classes; 2. applies NOT to derived associations; and 3. does NOT depend on possible navigation directions.) class A{} class B { int a1; } association a1 A<->B; class C { int c; } association A<->C; class A{} class B { int att; } association a1 A<->B; class C { int catt; } association A<->C;
0xD00XX The name(s) of your class diagram, classes, interfaces or enums do not conflict generated classes, i.e. are not used by the generator, too.
• Names with the suffix DataManager, Factory, Impl, Manager • Names with suffix SearchHandlerWorker
• Name CreateDummyValues • … class A; class ADataManager; classdiagram U { class USearchHandlerWorker; } class CreateDummyValues; class A; class A_DataManager; classdiagram U { class U_SearchHandlerWorker; } class MyCreateDummyValues;
CLASSES,INTERFACES AND ENUMS
ErrorCodes [Sch12] Please ensure that… Wrong example Correct example 0xU0533, 0xU0534 CD-1-07, CD-1-10, CD-1-14
Only interfaces are implemented. class A;
class B implements A;
class A;
class B extends A;
0xU0442 CD-1-49 Every class referenced by a qualifier contains an attribute with the qualifier’s name resp. type.
class A; class B; association a1 A[att1] -> B; class A; class B { int att1; } association a1 A[att1] -> B;
0xD0055 / Interfaces in your CD do NOT contain any attributes (because they are not supported by the dex-generator yet).
ATTRIBUTES
0xU0447 CD-3-01 Attribute values and their types are compatible. class A {
int att = false;
}
class A {
boolean att = false;
}
0xU0983, 0xU0450, 0xU0449?
CD-3-04 There is an initialization for derived attributes. class A {
derived int att; }
class A {
derived int att = 0;
}
0xU0451, 0xU0452
CD-3-03 Final attributes are initialized in the declaration. class A {
final int att;
}
class A {
final int att = 0;
}
0xU0453 CD-1-22 An interface’s non-final attributes are NOT initialized. interface I { int att = 0;
}
interface I {
final int att = 0;
} INHERITANCE
0xD0013 / Your CD model do NOT contain multi-inheritance (which is not supported by the dex-generator yet).
class A; class B;
class C extends A,B;
class A;
interface B;
class C extends A implements B;
0xU0531 CD-1-06, Your CD model do NOT contain inheritance cycles. class A extends B;
class B extends A;
class A extends B;
class B;
ErrorCodes [Sch12] Please ensure that… Wrong example Correct example
CD-1-12
0xU0496, 0xU0497, 0xU0499
CD-1-04 Classes only extend enums and interfaces. interface I;
class B extends I; enum E; class C extends E; class final A; class D extends A; interface I; class B implements I; enum E; class C; classA; class D extends A;
0xU0455 CD-1-20 If a superclass and its subclass each contain an attribute with the same name, thetype of the attribute in the subclass will be compatible with casting – otherwise the subclass’s attribute will be ignored.
class A { char att; } class B extends A { int att; } class A { char att; } class B extends A { char att; } DUPLICATES
0xU0504 CD-1-23 You avoid duplicates wrt constants in an enum. enum E {Foo, Bar, Foo} enum E {Foo1, Bar, Foo2}
0xU0244 All-1-03 You avoid duplicate wrt stereotypes. <<Val, Val>> class A; <<Val1, Val2>> class A; MULTIPLICITIES
0xU0240 All-1-04 Any multiplicity’s left bound is smaller than its right one. class A; class B; association A -> B [3..2]; class A; class B; association A -> B [2..3]; 9