Chapter 3 Building Structural Diagrams


Adding Getter and Setter operations to a classifier

Getter or Setter operations are special types of operations you create for an attribute. You create them for sending and receiving data values between attributes of a class or of an interface.

You create a Getter or a Setter operation from the list of attributes. For each attribute, you can create a Getter, a Setter, or both a Getter and Setter operations.

Operation Description
Getter Returns a value from an attribute
Setter Sets a value into an attribute

C# exception

In C#, if you have an attribute with the <<Event>> stereotype, the default methods are not Getter and Setter but Add and Remove. When you click the Add Accessors button, the Add and Remove methods are automatically added.

Steps To add a Getter and a Setter operation to a classifier from an attribute:

  1. Double-click a class or interface in the diagram to display its property sheet, and then click the Attributes tab.
  2. Select one or more attributes and then click the Add Accessors button at the bottom of the attributes tab.
  3. Click the Operations tab to view the newly created at the bottom of the list of operations. The values are grayed indicating that the names cannot be modified.
  4. Click OK.

 


Copyright (C) 2006. Sybase Inc. All rights reserved.