Attributes ​
This page focuses on details about attributes in general and how they can be created and modified as part of a meta-model.
Attribute Basics ​
Attributes specify for a class or model type the information that can be stored with instances of that class or model type. They are sometimes also called properties. An attribute value can be considered an "instance" of an attribute.
Different kinds of attributes are available in ADOxx. The kind of an attribute determines how it is used and interpreted by the platform. The following statements are relevant for all kinds of attributes, while specific details are described in the later sections:
- Attributes belong to a class.
- An attribute is owned by exactly one class, but is inherited by all sub-classes. All sub-classes "have" that attribute.
- An attribute has one specific type which controls what kind of values can be stored for it.
- An attribute has various facets which define their details. These depend on the attribute's type.
- The name of an attribute must be shorter than 250 characters.
- Attribute names are case-sensitive, meaning that
Duration
,duration
andduRatIon
are considered distinct attribute names. - The names of attributes in the same class must be unique. For example there can not be two attributes with the name
Duration
in the classStep
. This also applies to inherited attributes. - There can however be two attributes with the same name in entirely different classes. For example two attributes with the name
Duration
in the classesStep
andLeap
, assuming none of them is the other's super-class (ancestor). Each attribute however has a different internal identifier (ID).
- Attribute names are case-sensitive, meaning that
- Each attribute is internally identified by a unique integer number (its ID). This integer number is unique to an ADOxx installation, but it is not globally unique and can differ between ADOxx installations! For example the attribute
Duration
of the classStep
can have different IDs on different computers. - An attribute can be made available to the user through a Notebook (configured through the
AttrRep
) or be only available through programmatic means. - An attribute can also be made available through the graphical representation of the instances it belongs to (configured through the
GraphRep
).
Instance and Class Attributes ​
A "normal" attribute is an instance attribute as opposed to a class attribute. The difference between the two is where their value belongs to:
- The value of an instance attribute belongs to the instance of a class that has the attribute.
- The value of a class attribute belongs to the class that has the attribute.
Instance attributes can have a different value for each instance of a class. Different instances of the same class can have different values for the same attribute. Class attributes have exactly one value for the entire class and all of its instances and are typically used to configure a class.
Special Attributes ​
Special attributes are used by the ADOxx platform to configure the use and behavior of a class and thus of its instances. They have a specific semantic and are realized as class attributes where possible. In a sense they are similar to predefined classes, except that some of them are optional. A list of special attributes used by the ADOxx platform is provided in the special attributes section. Some examples for special attributes are:
- Whether or not a class is instantiable on model level is handled through the special attribute
ClassAbstract
. - The graphical notation and some possibilities for interaction are described through their special
GraphRep
attribute. - The specification of a Notebook for instances of a class is provided through their special
AttrRep
attribute. - The cardinalities between a (modelling) class and relation classes is described in the special attribute
Class cardinality
. - The position of an object is stored in the special attribute
Position
.
A custom meta-model can use its own special attributes to deal with various requirements and desired functionalities of a modelling language. These are however not specific to the ADOxx platform and are not covered in this documentation.
The Name Attribute ​
Every (modelling) class and Attribute Profile class inherits an attribute called Name
. It is used by instances of these classes to store their name, which can be up to 250 characters long. The Name
attribute does not directly show up in most views of the meta-model, but it can be accessed and manipulated programmatically like any other attribute.
Managing Attributes ​
Attributes are managed like classes through the class-hierarchy. For details on how to open the class-hierarchy see the section on managing classes.
Any changes are only applied to the database after the library is saved.
The following image shows the class-hierarchy for a Dynamic Library where the attributes of the __D-construct__
root class are visible with the options Metamodel and Class hierarchy available under View turned on.
Caution
The (Metamodel)
shown next to some attribute names is an indicator that it is a special attribute from an ADOxx built-in predefined class. It is not part of their name.
Select the or icons next to the class names to expand or shrink the class-hierarchy, showing or hiding their sub-classes and attributes. The buttons on the right of the dialog allow to create, copy and delete attributes.
Changes to the attributes can be saved by selecting the Save button or closing the class-hierarchy through the Close button. The ADOxx platform first performs some checks, informs about any possible issues via pop-up windows and at the end asks whether the changes should be saved to the database.
The attributes are listed after all the sub-classes of a class. Pay attention to the indentation to identify for which class an attribute is listed. The icon next to the attribute name provides some additional information:
Icon | Name | Description |
---|---|---|
Attribute | Basic icon for an attribute. Without any other icons it denotes a normal instance attribute owned by the class. | |
Class attribute | The rectangle indicates that it is a class attribute. Can be mixed with the arrow indicating an inherited attribute. | |
Inherited attribute | The arrow indicates that the attribute has been inherited and is owned by one of the super-classes. This distinction is relevant for the attribute facets. Can be mixed with the rectangle indicating a class attribute. | |
Inherited class attribute | Icon indicating that it is both an inherited attribute and a class attribute. | |
AttrRep attribute | Icon indicating the attribute for specifying the Notebook for the class. | |
GraphRep attribute | Icon indicating the attribute for specifying the graphical representation for the class. |
Creating an Attribute ​
- Open the class-hierarchy where the attribute should be created.
- Select the View button and turn on the options Metamodel and Class hierarchy.
- Select the class that should be the owner of the attribute.
- Select the New button and then either New attribute... or New class attribute... from the drop-down menu.
- Enter a name and specify the type for the new attribute and select Ok.
- For some types of attributes an additional dialog will open to specify some of the required attribute facets
Note that the name and type of an attribute can not be changed after it has been created. As a workaround it is possible to create a copy of the attribute with a different name and then delete the attribute, but this also deletes all the values that were already existing.
Modifying an Attribute ​
An attribute is configured by its attribute facets.
- Open the class-hierarchy where the attribute is located.
- Select the View button and turn on the options Metamodel and Class hierarchy.
- Select the attribute to modify and select Edit....
- Alternatively double click on the attribute in the class hierarchy.
- In the Notebook that opens modify the desired attribute facets.
- Select the Close button.
Copying Attributes ​
- Open the class-hierarchy where the attributes should be copied.
- Select the View button and turn on the options Metamodel and Class hierarchy.
- Select the attributes to copy.
- Select the Copy... button.
- Select the class where the attributes should be copied to.
- The selected class will be the owner of the attribute.
Deleting Attributes ​
- Open the class-hierarchy where the attributes should be deleted.
- Select the View button and turn on the options Metamodel and Class hierarchy.
- Select the attributes to be deleted.
- Select the Delete button.
- If asked whether to really delete an attribute select Yes or Yes, all.
- This dialog only appears for attributes that have been previously saved to the database.
Deleting an attribute also deletes all values for that attribute.
Best practices ​
- Avoid starting or ending the names of attributes with two underscore characters (
__
). These are typically used to indicate some special attributes. - Avoid using the same name for two attributes in the same class even if it is possible due to technicalities, like
Duration
andduration
.- Use a more descriptive name instead or provide some additional context to the name, for example in parentheses at the end of the name.
- Consider both the inheritance of attributes and the restriction of some facets when deciding which class should own an attribute.
- To identify an attribute rely on its name and the class it belongs, as the integer identifier (ID) can differ between installations.