Class diagrams

 

Definition

Class diagrams play a central role in object-oriented analysis and design.  They present a set of static model elements, their contents (internal structure) and their relationships with other elements.  The main elements presented in a class diagram are classes, packages, associations, generalizations and dependencies.

 

Class diagrams (an example is shown below) are created in packages, classes, interfaces, actors or collaborations.

 

An example of a class diagram

 

 

Creating classes and sub-classes

Classes are created in class diagrams by clicking on the  "Create a class" icon in the diagram palette and then clicking in the diagram at the point where you want the new class to appear.

 

Sub-classes are created in the same way, but instead of clicking in the background of the diagram, you should simply click inside the class that is going to contain the new sub-class.

 

 

Creating operations and attributes

Operations are created in class diagrams by clicking on the  "Create an operation" icon in the diagram palette and then clicking in the owner class.

 

Attributes are created in class diagrams by clicking on the  "Create an attribute" icon in the diagram palette and then clicking in the owner class.

 

 

Template classes

Template classes are models of classes, which must be instantiated to produce a real class, which is then in turn instantiated to produce an object. 

 

Template parameters can only be created in the explorer, using the  "Create a template parameter" icon.  When a template parameter is created in a class, it automatically appears in class diagrams containing the class in question.

 

A class can be linked to a template class through the {bind} tagged value on the class itself.

 

 

Creating an association class

An association class is a class which links other classes, and is both a class and an association.  An association class is a component of an association. 

 

The example below presents the creation of an association class between two classes.

 

Creating an association class

 

Steps:

1.      Create an association between the "Company" class and the "Person" class, by clicking on the  "Create an association" button, and then clicking on the origin class and the destination class.  The link then appears.

2.      Create the class which will serve as class association, by clicking on the  "Create a class" button.

3.      Create the association class, by clicking on the  "Create an association class" button, clicking on the class and then on the original association between the two original classes.

 

 

Throwing and catching exceptions

In Objecteering, exceptions are represented by signals.  The  ("Create an element import") icon is used to create use links stereotyped <<throw>> or <<catch>> between operations and signals.

 

Three uses of this feature are available:

 

Note:      Please note that for dependencies between an operation and a class or a signal, the Objecteering C++ and Java generators do not yet take these dependencies into account.

 

The figure below shows an example of a class diagram which contains a use link stereotyped <<catch>> (from the "serialize" operation belonging to the "Document" class towards the "FileSystemFull" signal) and another stereotyped <<throw>> (from the "write" operation belonging to the "fileServices" class towards the "FileSystemFull" signal).

 

Example of a class diagram including both <<catch>> and <<throw>> use links

 

To catch an exception, simply click on the  ("Create an element import") icon, and then click on the operation in question and then on the signal (as shown in example 1 in the above illustration).

 

To throw an exception, click on the  ("Create an element import") icon, and then firstly click on the signal and then on the operation in question (as shown in example 2 in the above illustration).  Please note that even though you first click on the signal and then on the operation, the link is created from the operation to the signal.

 

 

Creating a qualifier on an association

The creation of a qualifier on an association link can only be carried out in the explorer, by selecting the association concerned and clicking on the  "Create a qualifier" icon.  The qualifier created is, however, automatically presented in the class diagram after its creation in the explorer.

 

 

Migrating UML 1.4 class diagrams to UML 2 class diagrams

If your model contains class diagrams created using an earlier version of Objecteering, these UML 1.4 class diagrams are automatically migrated to UML 2 through the automatic creation of a UML 2 class diagram when the UML 1.4 class diagram is opened.  This UML 2 diagram has the same name as the earlier diagram, belongs to the same model element and is directly displayed.

 

The new diagram retains the following information from the migration of the earlier diagram:

 

Association labels are positioned using the new intelligent positioning system implemented in UML 2 diagrams.

 

Elements not managed by diagram migration are as follows:

 

Since the earlier UML 1.4 class diagram is conserved, it can still be opened after migration in the usual way (either by double-clicking on it in the Objecteering explorer, or through the "Edit" command in the context menu).  The diagram is then opened in read-only mode, meaning that only the zoom and grab functions are active.

 

We recommend that the UML 1.4 class diagram be deleted once it has been migrated.  If the new UML 2 class diagram is renamed, the migration procedure will once again be run the next time the UML 1.4 class diagram is opened.