To add attributes and operations to classes

  1. Select the class, either on the class diagram, or in the Model View tree.
  2. Right-click the mouse and choose either the Add New Item menuitem, or use the Add submenus as described above.
  3. Type the name of the attribute or operation. Use standard UML syntax to set the visibility, name and type (for attributes), or parameters and return type (for operations). The UML syntax for declaring attributes and operations is:
  • Attributes: {visibility}attrName:type[=expression]
  • Operations: {visibility}opName(param1:type, param2:type, ...):returnType

Where {visibility} is one of:

  • Public visibility
  • Private visibility
  • Protected visibility

When declaring attributes you can include an optional expression, which will become the initial value of the attribute. For example, the declaration:+myAttribute:int=17 declares a public attribute named myAttribute, of type int, which will have an initial value of 17.

An attribute can be made to be "derived" by prefixing its declaration string with a slash "/", or by selecting it and changing the Derived property to true in the Object Inspector. When you create a derived attribute, you will also need to open the source code for that attribute (right click the attribute and select the Open Source menuitem), and remove the [EcoAutoMaintained] .NET attribute. Otherwise, any code you write in the attribute's get/set methods will be overwritten when the IDE regenerates source code.

Note: Like all elements on the class diagram, attributes and operations can be individually selected and then configured using the Object Inspector.

Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook

Post a comment