Working with a Field

From RAD Studio
Jump to: navigation, search

Go Up to Class Diagram Procedures

We use the term field in Delphi projects and the term attribute in C++ and design projects. In this topic we will use these two terms as synonyms.

In implementation projects, it is possible to declare several fields on one line of the source code. However, on the diagram, each such field represents a separate entry in the Fields compartment of the appropriate container (class, interface or other). However, in the Code Editor, you can rename such fields, change visibility modifiers, set initial values, and so on. The Modeling applies all these modifications to the respective fields in the appropriate diagrams. Also you can copy and move such fields in diagrams (using context menu commands or drag-and-drop), and the pasted fields appear in the target containers as separate entries.

To rename a field

  1. In the Diagram View or Model View, select a field.
  2. Rename the selected field:
    • Press F2 to activate the in-place editor. Enter the new name to the field.
    • In the Object Inspector edit the Name field to rename the selected field.
    • You can also rename fields in the Code Editor.

To define the visibility modifier for a field

  1. In the Diagram View or Model View, select a field.
  2. Set the visibility modifier for the selected field:
    • In the Object Inspector, select one of the available visibility modifiers from the Visibility combo box.
    • You can also edit visibility modifiers in the Code Editor.

To define the stereotype for a field

  1. In the Diagram View or Model View, select a field.
  2. Set the stereotype for the selected field:
    • In the Object Inspector, use the Stereotype property to define the stereotype.
    • You can also define the stereotype in the Code Editor. Use the <stereotype> comment, like this:
/** <stereotype>Stereotype_Text</stereotype> */

To define modifiers, initial values, associated objects, and so on

  1. In the Diagram View or Model View, select a field.
  2. Set the desired property for the selected field:
    • In the Object Inspector, set the desired value to the appropriate property.
    • You can also define the desired values to some properties in the Code Editor using the keywords like static or the special comments like:
/* <author>Author_name</author> */


Such operations kept in sync the source code in the Code Editor and the model in the Diagram View or Model View.

See Also