Attributes

In this section, you will see how to insert new attributes in your classes from the class diagram graphical interface.


To create a new attribute, select New > Property in the class (or interface) contextual menu.

 



This launches an attribute creation dialog box. You have to set the attribute name, type, multiplicity, default value, visibility and modifiers. For an interface, the attribute is always static final.

 



After validating the dialog box, the attribute appears immediately in the class. If you click on the attribute, its code appears in the java editor area.
By default, the property concept is activated, so the attribute and its accessors are displayed as a single property. In this example, the attribute is private and is related to its public accessors in the java code.



If we don't want to use the Property concept, then select a class in the class diagram editor.
Open the popup >Preferences



Unselect the Use property concept checkbox.




The class diagram editor now shows private attributes and public methods.