Designing Attributes and Operations

I l @ ve RuBoard

During analysis, it was sufficient to specify only attribute and operations names . During design, data types and initial values must be specified for attributes and operations signatures must be supplied. A data type for an attribute may be a language-supplied type such as an integer or it may be a more complex type like a String from a class library. If the attribute must be initialized to a specific value when an object of the class is created, this information is added to the class. In methodology terms, the operation signature includes the parameter list and the return class. Again, parameters and return classes must be assigned a data type. Access controlpublic, protected, and privatemust be set for attributes and operations. Attributes are typically private whereas operations may be private or public. If the class is part of an inheritance hierarchy, attributes and operations may be set to protected to allow access to subclasses.

SETTING ATTRIBUTE DATA TYPES AND INITIAL VALUES IN RATIONAL ROSE

graphics/quatranirose_icon.gif
  1. Right-click to select the class in the browser or on a class diagram and make the shortcut menu visible.

  2. Select the Open Specification menu choice.

  3. Select the Attributes tab.

  4. Click to select the type and place the field in edit mode. Enter the desired type or select a type from the drop-down menu.

  5. Click to select the initial value and place the field in edit mode. Enter the desired initial value.

SETTING OPERATION SIGNATURES IN RATIONAL ROSE

graphics/quatranirose_icon.gif
  1. Right-click to select the class in the browser or on a class diagram and make the shortcut menu visible.

  2. Select the Open Specification menu choice.

  3. Select the Operations tab.

  4. Double-click on an operation to make the Operation Specification visible.

  5. Enter the return class on the General tab.

  6. Select the Detail tab.

  7. Right-click in the Arguments field to make the shortcut menu visible.

  8. Select the Insert menu choice. This will add an argument. Enter the name , data type, and default value for the argument.

  9. Click the OK button to close the Operation Specification.

  10. Click the OK button to close the Class Specification.

  11. To display the operation signature on a class diagram, either set the display as the default using the Tools:Options menu choice, or the Diagram tab.

  12. To display the operation signature on a class by class basis, select the class(es) and choose the Format: Show Operation Signature menu choice.

Note

Attribute and operation detail may also be set on a class diagram by selecting the displayed item and using the following format:

attribute : type = initial value

operation (argname : argtype = default) : return class


Some of the attribute and operation design decisions for the ESU Course Registration problem are shown in Figure 12-8.

Figure 12-8. Attribute and Operation Design Details

graphics/12fig08.jpg

I l @ ve RuBoard


Visual Modeling with Rational Rose 2002 and UML
Visual Modeling with Rational Rose 2002 and UML (3rd Edition)
ISBN: 0201729326
EAN: 2147483647
Year: 2002
Pages: 134

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net