-
Notifications
You must be signed in to change notification settings - Fork 3
Class Diagram Syntax
Claudia Loitsch edited this page Dec 22, 2016
·
30 revisions
- A class diagram always starts with
@start-cls
, ends with@end-cls
, and requires to put a title in quotation marks right after the start tag, e.g.@start-cls “My Title”
. In the second place, the default package “RootElement” must be declared withrootPackage RootElement
. So the basic structure of a class diagram look like the following example:
@start-cls „My Title“
rootPackage RootElement
@end-cls
- Unique identifier are used to define core UML elements, for instance, classes, associations, packages, interfaces, etc.
- Indentation are not relevant – everything can be formatted left-aligned. Though, spaces are relevant to distinguish between elements. Strings are not restricted in length and must be put in quotation marks.
- The actual description of an element, e.g. a class desciption, is included in braces and starts right after the element identifier. It is recommended to put the opening brace on the same line as the element identifier. The closing brace shall be put on a single line to facilitate finding enclosed element blocks:
class Classname{
}
- The order of elements within a class diagram is pre-defined and must be kept. At first, the imports are defined followed by classifiers, associations, and packages. Details of each element desciption is given in the subsequent sections.
- A class is introduced with the identifier
class
followed by an unique id. The id should not include empty spaces and should follow the CamelCase convention, e.g.class MyClass
. The id must put in quotation marks if empty spaces are used, e.g.class "My Class"
. In terms of long class names, an alias can be put right after the id - introduced with as. For instance,class “LongClassName” as Long
. - To specify the visibility of a class, the following notations must be placed before the keyword
class
: -
public class
or+ class
for a public class (default, if not visibility is given) -
private class
or- class
for a private class -
protected class
or#
class for a protected class -
~ class
for a package - To specify a class to be abstract, the keyword
abstract
is placed before the keyword class and after the visibility: private abstract class MyClass
- The definition of attributes and methods is placed within braces after the definition of a class. At first the name is given, followed by a colon, followed by the type:
attributename: attributetype
- The following types are supported:
string
,int
,double
,boolean
,char
,byte
,short
,long
,float
.
Modeling Environment
Tools