A Generic is a specific type of chart with an explicit interface (“Data Encapsulation”), enabling a modular development of components. Although both Activity Charts and Statecharts might be defined as Generics, use only generic Activity Charts in system modeling (exception: Testbench Charts).
Generics should not be seen from a model reuse perspective alone. They are also a powerful means in a team-based development. Models of the different team members should always be defined on the top-level as Generics thus forcing a clear interface definition. This facilitates the later integration into the overall system significantly. A chart can be changed at any time from regular to generic and vice versa.
Note: Testbench Charts do not have any scope into generic charts. Therefore, modeling and model validation should be performed with the regular chart prior to its change to a Generic.The nesting of Generics (“Generics in Generics”) should be minimized even though Rational Statemate supports it. Debugging the model might become troublesome due to the difficulty in referencing parameters. Three levels depth should be sufficient.
The following figure depicts the top-level structure of a Generic Activity. Each generic formal parameter is shown graphically by a flow making it easy to determine from the diagram whether the parameter is used as an input, output or both input and output. When using large complex data structures, only those elements that are really needed should be passed instead of the entire structure.
External Activities of a top-level generic chart should not show any details of the origin and destination of the I/O parameters. Their names should be simply INPUT and OUTPUT.
Once a generic chart is created and validated it can be archived as a component (see the Example of a Library Component figure) and entered into a model library.
Library Components can be used in other models by simply dragging the component from the library and dropping it into the respective chart.
Note: If a Library Component is edited in the library, any modeler who has created a dynamic link to the component, rather than just copying it sees the new change taking effect the next time the simulation is run.