Tuesday, 21 July 2020

IBM Rational Rhapsody Tip #80 - Package Diagrams in SysML/UML (Simple)

Slightly delayed on getting this one out but this is the seventh in a series of videos on the different types of diagrams in UML and SysML.

This short video (unusually with audio!) covers Package Diagrams one of the simplest structure diagrams that SysML inherits unmodified from UML. In general they show containment and dependency relationships between packages, although it's important to note that any of the structural elements might also be shown such as nested hierarchies of requirements or blocks.
















The video covers some tips and tricks to get the most out of Rhapsody including setting the TreeContainmentStyle property depending on the style of containment relationship that you want to show. The video uses Rhapsody 9.0.1 (released July 7 2020).

Here's the transcript (in case people need additional info to help understand):

This is the seventh in my series of videos on the different diagrams in the UML and SysML languages. In this video, I’m going to cover how Package Diagrams are implemented in IBM Rhapsody.

Package diagrams - like use case, sequence, and state machine diagrams, are inherited into the Systems Modeling Language directly from the UML without modification.

The PDF I’m showing here is actually the first UML 2.0 spec from 2003. Here we can see that it states that there are no strict boundaries between the different structure diagram types, and it is possible to display elements such as objects, classes and packages, in any of the variations, it’s just that usually package diagrams are focused - as you’d expect - on packages.

If I switch to the UML menus in Rhapsody so that the SysML profile is not active, then you’ll notice that Rhapsody doesn’t have an explicit Package Diagram type, rather it expects an Object Model Diagram to be used for this purpose.

It does this on the basis that the Object Model Diagram drawing toolbar already allowed in 2003, the modeler to draw any of the structure diagram elements including objects, classes and packages.

If I switch back to the SysML menus, however, you’ll see that there is an explicit menu for a Package Diagram, and that the SysML profile has added this to Rhapsody’s pop-up menus.

Package diagrams are one of the simplest diagrams in the UML’SysML language.

Since all diagrams SysML have a diagram frame, the fact that this is a package diagram can be seen from the pkg abbreviation in the top left-hand corner of the frame.
Packages in Rhapsody are shown with a blue folder icon. They act like folders and are used to split up and organize model elements for access and understandability.

In the case of Rhapsody, they also map to separate units, or files, and hence form the basis of configuration management operations like check in and check out, and for sharing of common model elements between different projects.

Packages, like folders on a file system, can be nested underneath other packages. The package diagram allows useful groupings such as these to be visualised on a diagram.
If you try to show something out of context, then you can see here, that Rhapsody denotes this with a dashed line.

In this instance, I could right-click to change its ownership, in which case the browser will re-structured to match the diagram.
The Nesting style shown here is using Rhapsody’s default display option.

If we look in the latest SysML specification, Figure D.3 here shows us the two different containment notations. Both mechanisms shown here are possible in Rhapsody, but you may need to set a display property to get the top-one to work.

Let’s have a go at drawing this diagram. I’ll add a new package diagram to the HSUVModel package, but before doing anything else, I’m going to set a display property on the diagram called TreeContainmentStyle.

This notation style is also referred to as “alternative membership notation”. The property could be set at diagram, package, or project level.

It can be used to depict hierarchical relationships, not just with packages but also other model elements such as requirements, diagrams, and blocks.

With Tree Containment Style set, if I drag elements from the browser then the containment relationship will be populated on the diagram.

Before doing this, I’m just going to set the default display size for packages, to the one that I’ve got here. These means that when I drop elements on the diagram they’ll take this as their default size.

Notice that in 8.4 onward's I can drag a group of elements from the browser, by dragging the category to select them.

Here we can see that any existing containment relations we will automatically populated, if we drag something on to the diagram from the browser.

Conversely, If I remove the relationship in the model then the diagrams will be updated accordingly to remove the containment display, so that the diagram and model are always in sync.

If the related elements are already on the diagram, then we can choose to populate existing relationship using the Complete relations menu in the main Layout toolbar.
Notice that I can drag any model element on to the diagram.

For example, here is the containment relation shown between the HSUV Structure package and the Automotive Domain block.

The second form of the containment notation will still work with the TreeContainmentStyle property set. This is the default way of showing the HSUV Specification is underneath the HSUV Requirements package.

Package diagrams are also used to show other types of relationship between packages. Most commonly these are dependency relationships with stereotypes applied. The stereotypes could be built in or user-defined.

Here I am saying that the HSUV Use Cases package has a Usage dependency on elements in the HSUV Requirements package.

Profiles are types of packages and can be used on package diagrams in the same way.
If a profile is not globally applied but contains properties that you want to apply to only part of the project, then it can be applied to a package and its children using a built-in Rhapsody stereotype called AppliedProfile.

Sometimes I use colour to differentiate profiles from packages on the diagram. There are no conventions in the use of colour in SysML or Rhapsody, however. Of course, you must be careful in using colour alone as a reasonable proportion of the population is colour blind, hence other formatting could be used.

Don’t forget that you need to set the TreeContainmentStyle property if you want to show containment links on diagrams and that it’s perfectly possible for package diagrams to contain model elements other than packages.

There we have it. Package diagrams. One of the simplest structure diagrams that SysML inherits directly from UML without modification.

My name is Fraser Chadburn and I specialist in tool-based training and consulting in IBM products and in particular in setting up Rhapsody using domain-specific profiles.

Using Java automation, I can simplify and speed up modeling tasks so that users can focus on creative and fun systems and software engineering.

If you do have any questions, then feel free to email me.

No comments:

Post a comment

Note: only a member of this blog may post a comment.