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.











No comments:

Post a Comment

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