Wednesday, 23 October 2019

Rational Rhapsody Tip #67 - What are implicit classes? (Intermediate)

In this short tips and tricks video for IBM Rational Rhapsody I give an overview of how objects in Rhapsody can be used for modeling software or systems architectures without using classes. I then compare this with the benefits of using classes. The key thing is that if you create an object in Rhapsody that is not typed, then it can support all the concepts that a class can. It does this by creating an implicit class under-the-hood, but just showing the object in the browser. The key reason you expose classes is where you need to enable re-use, or a separation of concern between the definition of an element and its usage. This is why I tend to recommend always using classes (in UML), or blocks (in SysML), if you can. It means you can have a consistent approach that copes with the future.
















Rhapsody creates an implicit class under-the-hood whenever you create an untyped Object. This enables Objects to have ports and statecharts. They can also have operations and attributes.
































This is the basis of Rhapsody in C's optional File rather than Class-based mapping to the C programming language. A File in Rhapsody in C is a type of Object where the attributes and operations are mapped to variables and functions in .h/.c files.










Using only objects you can created nested hierarchies to visual a software or system architecture. The implicit class under the hood enables you to exploit composite structure notation with ports, parts and connectors without needing to expose classes in the browser.








There are good reasons, however, to expose classes. The main reason is to enable re-use of the underlying classes features in a different context. Suppose, for example, that you want to do represent a Function block that has inputs, outputs and requirements, but is used by two different features. Well, by exposing the class you can re-use the function in a different composite structure.



















Two parts are now typed by the same class. The visual representation of each part (it's operations, attributes, statecharts and ports etc) are defined by the class.












A flatter browser results when you do this and it also means that you can move classes/blocks that define the properties of an element to a different package in the model from the classes that use them. This can assist with re-use of library functions/blocks/classes, or the creation of blocks/classes by different users than the modeler who is using them.











Of course, the user now needs to be aware of the different between objects/parts and classes in UML. Note: A part is the name given to an object that is declared in the context of another class, and is the basis of component-based design in UML (and SysML).













Connectors and links are used in a composite structure to wire together parts. They are created in the context of the owning class. These work when both implicit and explicit classes are used because the connector is a link between parts/objects, rather than classes.











One hundred and seventy eight - 178

I've got a break of work, so I've been looking at my statistics for the year so far. 178 is the number of different people I've trained this year on Rhapsody. This is detailed 'nuts-and-bolts of the tool/language' with hands-on labs (rather than fluffy UML 'look how pretty these boxes and ellipses') training.

A few things I'm looking at are:
a) Offering web-based public training on a regular cycle (1 per quarter).
b) Offering SysML for automotive software architecture, looking at key adaptations to automotive market segment for 26262 and A-SPICE.

p.s. My latest training adds an optional day that combines C++ or C code generation with the use of RMM for storing the models and DNG for linking to requirements as external artefacts in the Rhapsody browser.

Monday, 7 October 2019

Rational Rhapsody Tip #66 - What are .hep files used for? (Intermediate)

.hep files are IBM Rational Rhapsody helper files. They are used to extend Rhapsody's menus and usually associated with profiles. Many of Rhapsody's standard profiles use .hep files to add additional menus when the profile is present. This video illustrates a couple that are part of Rhapsody's factory SysML profile.

















Hep files can invoke a Java plugin that runs in process, or alternatively they can invoke an external Java application. This extract from the SysML.hep shows an example of how a helper file can load a Java plugin


The plugin is associated with a name and the name is then associated with new context menu commands. For example, a Create Swimlanes From Parts command is added to the right-click menu for Activity Diagrams.












Here's an example of the results. In this instance the Java extension is running as a plugin. This means that it's running in the JRE loaded into the Rhapsody process.

It's also possible to get a helper file to invoke a Java application that is a separate from Rhapsody. In this instance you may need to provide additional arguments to tell it what libraries and classpaths to use.

The Elaborate Connector Via Ports... command added by the SysML.hep is an example of invoking an external application. In this instance a separate Java application is launched, with a separate GUI, to provide the extended functionality.

By convention, if a profile has a hep file with the same name, then the helper file will be loaded when the profile is loaded. For example, the SysML.sbs has a SysML.hep file in the same folder. Another way to get a helper file to load is using the General::Model::HelpersFile property.


That said, associating a .hep file with a profile is often the best way because you can bring in other extensions at the same time, such as stereotypes, tags, and Rhapsody properties or property files.












This Create Use Case package structure command is an example from a profile that I wrote called the ExecutableMBSEProfile (which is one of the optional profiles in my open source SysMLHelper project). It adds menus to accelerate an MBSE method based on use case analysis to define system requirements



As well as creating the model structure, it also creates to triggers in Rhapsody. For example, automatically moving requirements created in the use case diagrams package into a separate requirements package.









Finally, there are other properties that can be used to associated .hep files with models or profiles. If you have more than one .hep file that you want your profile to load then you could use the General::Model::AdditionalHelperFiles property.



Friday, 13 September 2019

Rational Rhapsody Tip #65 - Linking to Jazz/qm test cases using Rhapsody Model Manager (6.0.6)

"Can I link to Jazz/qm test cases directly from Rhapsody?" came up recently in one of my training's.

Here's a short video that shows how...
















The first thing to note is that the Rhapsody project needs to be stored in the Jazz/am application (aka Rhapsody Model Manager). This Jazz/am project area currently associated with requirements in Jazz/rm:



















Note how external artifacts representing requirements can be placed on any diagram.

















Here we can also see the OSLC links to other Jazz applications.














Jazz/am allows web browser access to the Rhapsody elements and diagrams.

To work with external test cases we need to first associate the Rhapsody Jazz/am project area with a Jazz/qm project area. I'll add an association to the Jazz/qm project area to consume Architecture Elements provided by Jazz/am.















When you close and re-open the Rhapsody project to get the Remote Artifacts Package to show the new association.











With OSLC linking, the requirements are not stored in Rhapsody, just the links. We can choose to login to access remote artifacts.









Let's add some relationships to tests in Jazz/qm. There's an Add New > OSLC Link on the diagrams right-click menu.








There's also an OSLC Links tab in the Features window.
















For a Validated By link type, the picker allows me to select existing or create new test case.















The OSLC link is now shown in the OSLC Links tab.












The test case shows Validates Architecture Elements links to the Rhapsody elements.




















You can use the Show in Rhapsody button to navigate to the Rhapsody client.












Jazz/qm test cases can be dragged on to diagrams similar to requirements.









... and Validated By OSLC links can be added by drawing a dependency.




Let's try again, this time with an activity diagram.














With the OSLC delegated user interface we can also create new test cases in Jazz/qm.












The rich hover in Jazz/qm allows the test engineer to view or jump to the Rhapsody element or diagram.





























Sunday, 1 September 2019

Rational Rhapsody Tip #64 - Customizing Rhapsody's C/C++ code generator using a simplifier plugin

I've been doing more training lately with the IBM Rational Rhapsody Developer Edition. This has promoted me to show a few videos on the fundamentals of C/C++ code generation. This video gives an "under the hood" look at the two stage process that underlies the built-in C/C++ code generation technology. Based on a modified version of the UsersSimplifiers.rpy project in the Rhapsody samples folder, it shows how we can use plugin customisation to make a single change to the generated code for many files.
















Not many people realize that Rhapsody's own C and C++ code generator is based on a two stage process starting with a model-to-model transform. We can view this model-to-model transform by setting the CPP_CG::Configuration::ShowCgSimplifiedModelPackage property and regenerating the code.


The results of the "simplifier" step will then be shown in the Rhapsody browser. This "simplification" takes into account diagrams, properties and other settings in the model. The model is called 'simplified' because it is flattened out into just types, attributes, operations and relations, e.g., statecharts are converted into C/C++ operations that will implement them.


The user model has the diagrams and properties and other settings that determine what to generate. Whereas the simplified model has a simplified metamodel that has a direct correspondence with the code that will be written into the .h/.cpp/.c files

So, why make the simplified model available in the browser? Well, it's because it's possible to customize this simplification step.

This project is a modified version of the UserSimplifiers sample in the Rhapsody installation.


Let's look at an example of a call-back hook available during C/C++ code generation. This plugin and these hooks will be pulled into the Rhapsody process when the project is loaded. In this example, this post simplication call-back checks for a «SingletonPattern» stereotype on classes.


If present, the Java plugin adds additional elements to the simplified model prior to Rhapsody writing the .h/.cpp files.


Let's re-generate again to a different configuration's folder to view its effect. First we need to set the stereotype that the post simplification hook is looking for.


The simplified model now has additional elements added by the simplification plugin.


The active code view shows us the .h/.cpp files that were generated. It includes user-defined methods as well as operations/attributes automatically generated. We can view the differences using a textual diff tool


Let's look at another example, an onPostSimplication call-back for operations. This adds a call the Reporter singleton class to the body of operations.


To get the simplifier plugin change to be reloaded, we need to completely exit and re-launch Rhapsody. When we open the sample model the plugin will be loaded into the Rhapsody process (due to a profile that loads a .hep profile).

Like pretty much everything in Rhapsody, the simplifier is controlled through Rhapsody properties. Here we can see that the stereotype is setting CPP_CG::Operation::Simplify to ByUserPostDefault.


With the simplifier plugin now active for operations, let's re-generate the code. We can then view the results in the textual differencing tool. This code was added by the simplifier plugin.


Like adding a new gear to your process, using customisations like this we can make a single change to the generated code for many files.

Friday, 30 August 2019

I've updated my installation guide on Slideshare to IBM Rational Rhapsody version 8.4

In my view it is a waste of your effort to install Rhapsody using its default settings as you won't get everything you may need and ultimately you'll need to uninstall and re-install to put things right.

The following is my latest installation guide. It provides the explicit steps that I recommend. In this guide, I've moved to suggesting you install for all users, rather than providing the choice, so that the decision is consistent. This seems to be the preference that most IT packaging teams want to opt for.

The guide includes steps to both obtain an evaluation and to validate that the compiler is working. The guide that therefore be used as a starting point for performing a Rhapsody evaluation.