UML Class Diagrams

The role of UML Class Diagrams in the forward engineering of object-oriented software systems is to model the static design view of a system. When applied to the reverse engineering of an existing system, this same view offers the possibility of improved understanding and analysis. By mapping C++ and Java source code constructs to the underlying language-independent UML Class Diagram constructs, Imagix 4D is able to apply its comprehensive database to generate informative class diagrams. When combined with the ability to focus on specific areas of the software and to control the level of detail, these diagrams provide users a valuable tool for program comprehension and analysis.

As defined in the Unified Modeling Language standard, a class diagram shows a set of classes, interfaces, and collaborations and their relationships. These relationships include generalization, aggregation and association. Under C++ and Java, the classes, interfaces, and collaborations align directly with classes and templates. And both languages incorporate generalization via class inheritance.

So the starting point for a UML Class Diagram resembles a class inheritance hierarchy graph, where the diagram shows which classes inherit from which other classes. This is extended by information about the class membership.

The essential class to class relationship is generalization / inheritance (blue line). UML convention is to use a 3-compartment box to represent a class, showing the class’s name, the class’s attributes / data members, and the class’s operations / function members.

UML associations also map directly to C++ and Java constructs, specifically to relationships between individual class members, such as calls, sets, or reads. In Imagix 4D UML Class Diagrams, display of associations can be turned on and off, and the individual relationship types to display can be selected. For example, a given analysis might study just the calls between class member functions, and disable other relationship types in the diagram.

UML aggregations align less directly with C++ and Java constructs. To generate information about aggregation relationships, Imagix 4D analyzes where a class is used as a type for a variable. The class container of such a variable becomes the aggregate while the class being used is the component. This analysis also tracks the multiplicity involved in such aggregations.

Aggregations are represented by the turquoise lines between the class boxes, with the numbers indicating multiplicity. Among associations, calls between class members show up as red lines, and overrides show up as green lines. If sets and reads relationships are enabled in the diagram, the lack of orange and aqua lines between class members indicates that no member variables are being set or read among the visible classes.

The significant challenges in using UML Class Diagrams for understanding and analyzing the class design of an actual software system involve scope and scale. When representing a real-world software system, a full UML Class Diagram quickly becomes too large to view in a useable way. To be useful, a UML Class Diagram must be easy to focus on the portions of the class structure relevant to the issue being studied. And the diagram must offer levels of abstraction even among those portions being viewed, so that lesser relevant data supports but does not overwhelm the critical information.

As with all Imagix 4D graphs, graphical querying enables the UML Class Diagram to be focused on the specific portions of code a user wants to examine. This means that users control which classes appear in the diagram, and are able to expand or trim the diagram to maintain the focus on where the analysis leads. The full set of Imagix 4D graphical queries are available for manipulating this focus. Specific classes can be added or hidden. The graph can be expanded up and down the class inheritance hierarchies or member associations. Classes having specific characteristics, such as file location, scope, or object-oriented metrics values, can be identified and added or removed to the graph.

Graphical querying functionality includes context sensitive menus that enable classes to be added to the diagram based on their inheritance, aggregation or association relationships with classes or class members already included in the diagram.

For dealing with issues of scale, Imagix 4D's class diagrams offer two approaches that filter the detail displayed about specific classes. The first of these is to limit which members are listed in the boxes representing classes. One setting is to display only those members that have association relationships with members from other visible classes. By applying this filter and restricting which association relationship types are displayed, the display of the class members can be reduced to just those members of most interest.

Limiting displayed members to just those that have selected associations with other visible classes reduces the size and information content of individual class boxes.

The second approach is to collapse a class's members, removing the individual members from the display. Attribute members are replaced with one placeholder, the operation members with a second. When this approach is used, the association relationship lines representing inbound and outbound associations of those collapsed members are also collapsed.

This approach results in a class diagram that is greatly reduced in size and complexity. By specifying which classes are expanded and which are collapsed, users are able to control which portions of the class design are shown in more detail and which provide more abstract context. As the focus of an analysis evolves, the collapsing of classes can be appropriately shifted.

When classes are collapsed in the diagram, their inbound and outbound relationships are also collapsed. Here the calls from XMLHepRepWriter indicate the specific member functions involved, while the members of AbstractXMLWrter being called are simplied.

An alternative under this second approach is to leave the entire diagram collapsed, and to use complementary displays to drill down into design specifics. Clicking on a placeholder for collapsed class members or a line representing collapsed association relationships focuses the Symbol panel on the underlying details.

Clicking on the abstract association line between classes XMLHepRepWriter and ZipOutputStream causes the Symbol panel to display all calls between the 17 member functions of XMLHepRepWriter and the 6 member functions of ZipOutputStream. Actual source code for these calls can be viewed in the Symbol panel's Usage tab.

Whether expanding just selected portions of the class diagram, or leaving it fully collapsed and using the Symbol panel to explore details, Imagix 4D's UML Class Diagram is able to practically examine a much larger portion of a class design than is feasible with a traditional, full expanded class diagram. Combining this with Imagix 4D's graphical querying capabilities to focus the diagram on the specific classes of interest results in a useful solution for understanding and analyzing real-world class designs.

Using the UML
Class Diagrams