Altova UModel 2025 Enterprise Edition

This tutorial section illustrates the following tasks:

 

Add an abstract class to an existing class diagram

Add class properties and operations, and define parameters as well as their direction and type

Add a return type to an operation

Change icons to UML conformant symbols

Delete and hide class properties and operations

Create a composite association between two classes.

 

To proceed, run UModel and open the BankView-start.ump project (see also Opening the Tutorial Project).

 

Adding an abstract class

The diagram to which the abstract class will be added is called "BankView Main" and can be opened as follows:

 

1.In the Diagram Tree window, expand the "Class Diagrams" package to display all class diagrams contained in the project.

um_class_01

2.Do one of the following:

 

Double-click the "BankView Main" diagram icon.

Right-click the diagram, and select Open diagram from the context menu.

 

Note:It is also possible to open the diagram from the Model Tree window. First, locate the diagram under the package "Root | Design-phase | BankView | com | altova | bankview", and then use either of the methods above to open it.

 

Two concrete classes with a composite association between them are visible in the class diagram.

um_class_02

"BankView Main" diagram

The new abstract class can be added as follows:

 

1.Click the Class ic-class toolbar button, and then click to the right of the Bank class to insert the new class.

2.Double-click the name of the new class and change it to Account.

um_class_03

3.In the Properties window, select the abstract check box to make the class abstract. The class title is now displayed in italic, which is the identifying characteristic of abstract classes.

um_class_05

4.In the code file name text box, enter "Account.java" to define the Java class.

um_class_04

 

Adding properties to a class

1.Right-click the "Account" class and select New | Property, or press F7. A default property Property1 is inserted with stereotype identifiers << >>.

um_class_06

2.Change the property name to balance, and then enter a colon ( : ) character. A drop-down list containing all valid types is displayed.

3.Type "f", and press Enter to insert the return type "float". Note that drop-down lists are case sensitive.

um_class_07

4.Continue on the same line by appending "=0" to define the default value.

5.Using the same method as above, create a new property id of type String.

um_class_08

 

Adding operations to a class

1.Right-click the Account class and select New | Operation, or press F8.

2.Enter "Account()" as operation name. Notice that the stereotype has changed to <<constructor>>, since the operation name is the same as the class name.

um_class_09

3.Using the same method as above, add two more operations, namely, getBalance():float and getId():String.

um_class_10

 

Let's now add a new operation which takes a parameter. We will also specify the parameter direction and type.

 

1.Press F8 to create another operation, collectAccountInfo().

2.Place the mouse cursor within the brackets and start typing "i". A drop-down list opens, allowing you to select the parameter direction: in, inout, or out.

um_class_11

3.Select "in" from the drop-down list, enter a space, and continue editing on the same line.

4.Enter "bankAPI" as parameter name and then a colon ( : ). A drop-down list opens, allowing you to select the parameter type.

um_class_12

5.Select IBankAPI from the drop-down list.

 

Adding a return type to an operation

So far, the operation parameter has been added, but it does not have a return type yet. To add a return type:

 

1.Place the mouse cursor after the close parenthesis character ")" and enter a colon ( : ). A drop-down list opens, allowing you to select a return type.

2.Press the "b" key and select boolean as data type.

um_class_13

 

To specify an operation's visibility (for example, "private", "protected", "public"), click the icon preceding the operation name, and select the required value, for example:

um_class_14

The visibility "package" is applicable for Java. In C#, use "package" to specify visibility as "internal". For information about how UModel elements map to constructs in each language, see UModel Element Mappings.

 

Changing icons to UML conformant symbols

The visibility icons can be changed to UML conformant symbols if necessary, as follows:

 

1.In the Styles window, select Project Styles from the top drop-down list.

2.Scroll down to the Show Visibility setting, and select UML Style.

 

Deleting and hiding class properties and operations from a Class diagram

Press F8 to add a dummy operation Operation1 to the Account class.

 

To delete the dummy operation, select it and then press Delete. (Alternatively, right-click it and select Delete from the context menu). A message box appears asking if you want to delete the element from the project. Click Yes to delete Operation1 from the class diagram as well as from the project.

 

To delete the operation from the class in the diagram, but not from the project, press the Ctrl+Delete. This hides the operation from the diagram, although it continues to exist in the project. Classes with hidden members are displayed with an ellipsis ( ... ) character, as shown below:

um_class_15

A class with hidden operations

To unhide the operation, double-click the ellipsis at the bottom of the class. A dialog box appears where you can choose the elements that should be visible on the diagram, for example:

um_class_16

"Visible elements" dialog box

It is possible to configure UModel not to display a message box when you attempt to delete an object from the diagram, as follows:

 

1.On the Tools menu, click Options.

2.Click the Editing tab.

3.Under Ask before deleting from project, clear the in diagrams check box.

 

Creating a composition association between the Bank and Account classes

1.Click the Composition ic-comp-ass toolbar button, and then drag from the Bank class to the Account class. The class is highlighted when the association can be made. A new property (Property1:Account) is created in the Bank class, and a composite association arrow joins the two classes.

um_class_17

2.Double click the new Property1 property in the Bank class and change it to "accounts", being sure not to delete the Account type definition (displayed in teal/green).

3.Press the End keyboard key to place the text cursor at the end of the line.

4.Enter the open square bracket character ( [ ) and select asterisk ( * ) from the dropdown list. This defines the multiplicity, namely, the fact that a bank can have many accounts.

um_class_18

Notice that the multiplicity range previously added to the diagram is also visible in the Properties window:

um_class_19

© 2018-2024 Altova GmbH