Visualization support

advertisement
Author: Manish (Manish Paul/India/IBM)
1. Introduction
Rational® Software Architect (RSA) v 8.0 introduces modeling, code generation and
visualization support for Visual Basic. This article will describe how to work with
Microsoft .NET solutions in Rational Software Architect and how to create diagrams
(Class, Sequence, and Browse Diagrams) from existing Visual Basic code and .NET
assemblies.
RSA allows you to visually depict Visual Basic code elements (Class, Interface,
Structure, Module, Enumeration etc), using class diagrams. It also provides support for
you to review the structure of the application by viewing relationships between various
.NET elements using Browse and Topic diagrams. In addition, it lets you depict typical
interactions between .NET classes in Sequence diagrams.
2. Working with Visual Studio projects in RSA.
Microsoft® .Net support in Rational Software Architect is designed to compliment the
use of Microsoft® Visual Studio 2005 OR Microsoft® Visual Studio 2008. This
approach needs solution containing the Visual Basic projects that are to be modeled in
RSA should always be open in Visual Studio whenever RSA is in use.
2.1 Integration with Visual Studio 2005 and Visual Studio 2008
The integration with Microsoft Visual Studio IDE means that you can import .NET
solutions from Visual Studio IDE into the RSA workspace as linked resources and use
available projects as a target for code generation. The default integrated development
environment (IDE) that RSA looks for is Visual Studio 2008. As Figure 1 shows, you can
change the preference to importing Visual Studio 2005 or Visual Studio 2008 by
selecting Windows > Preferences > Modeling > .Net Modeling. After the designated
IDE is set in the Preferences page, RSA makes sure that a solution from that designated
IDE is imported. Otherwise, it will produce an error notice.
Author: Manish (Manish Paul/India/IBM)
Figure1: Preferences page for Visual Studio IDE selection
2.2 Importing Visual Studio projects into Rational Modeling Extension
To work with Visual Basic projects, you first have to import the projects into RSA. This
can easily be done using the .NET Solution Import wizard, which you can open from File
> Import > Others > .NET Solution (as shown in Figure 2).
Author: Manish (Manish Paul/India/IBM)
Figure 2: .Net Solution import wizard – Page 1
The path to the solution file should be provided in the first page of import wizard
(illustrated in Figure 3.). Import wizard will parse the solution file and will list the
projects present in solution. After you successfully finish importing the .Net solution,
RSA will create corresponding Eclipse projects with same name as Visual Studio projects
in RSA workspace. The .Net Assemblies referenced in project will be listed under “
References” folder inside Eclipse project and Visual Basic code element will be added to
corresponding files/artifacts in RSA workspace. Both .Net Assembly references and
Visual Basic files/artifacts are imported to RSA workspace as linked resources.
Author: Manish (Manish Paul/India/IBM)
Figure 3: .Net Solution import wizard – Page 2
Figure 4: .Net Solution import wizard – Page3
Author: Manish (Manish Paul/India/IBM)
3. Visualization of Visual Basic elements
3.1 Visualize menu
The Visualize menu, shown in Figure 5, allows you to add the selected element(s) to a
new Sequence Diagram, Topic Diagram, or Class Diagram. You can also explore the
selected element(s) using the Explore in Browse Diagram command.
Figure 5: Visualize menu options
3.2 Visualizing to a Class Diagram
The Visual Basic elements can be visualized to ‘Class Diagram’ by simply drag-and-drop
to existing Class Diagram OR by right click Visualize->Add to Current Diagram/Add
Author: Manish (Manish Paul/India/IBM)
to New Diagram-> Class Diagram. Visual Basic elements are represented as EMF
objects appropriately stereotyped.
Figure 6 illustrates the visualization of Visual Basic code elements ‘Banking Application’
solution.
Figure 6: Visual Basic elements visualized in Class Diagram
Few key points to remember:
 The visualized elements are representation of elements in Visual Basic code and
are therefore read-only elements which cannot be modified in RSA.
 You can navigate to the corresponding element in Visual Studio IDE by double
clicking on visualized element.
 Reflecting code changes in visualized elements:
1. Any changes in the code will be reflected in corresponding visualized element
only when the affected artifacts are refreshed in PE.
 Visualization will not update the diagrams with code refactoring changes like:
1. Refactoring of type declaration (Class/Enum/structure/Interface/Module) or
namespaces. On refreshing the linked resource, the corresponding visualized
element will be shown as broken reference.
2. Deletion of type declaration or namespace will not remove the visualized
element from diagram. Instead it will be displayed as broken reference.
Author: Manish (Manish Paul/India/IBM)
3.2.1 Show Related Elements
Show Related Elements is a very useful feature that helps you query for related
elements on a class diagram. In RSA the Show Related Elements action is
available by right-clicking any visualized Visual Basic element on the Class
Diagram. The Show Related Elements option is present in the Filters submenu:
Right click -> Filters->Show Related Elements…
This will bring up Show Related Element dialog (as shown in Figure 7). You
create a custom query OR select a predefined query to set the criteria for
displaying the related elements
Figure 7: Show Related Element dialog
Custom Query:
Lists the set of predefined queries.
Relationship Types:
Lists the relationships that will be displayed in class
diagram (if selected).
Expansion Direction:
Option to display only incoming relationship OR outgoing
relationship OR both to be displayed in class diagram.
For example, if you wish to see the super class hierarchy
of the selected element, select Outgoing. In order to view
the subclass hierarchy, select Incoming.
Levels:
Specify the number of levels to display in the
Relationship types hierarchy.
Author: Manish (Manish Paul/India/IBM)
After providing all detail if you proceed with Show Related Elements; all related
elements as per the query selected or defined.
Figure 8. displays the result of Show Related Elements query for ‘CurrentAccout’
class in imported ‘Accounts’ project of ‘Banking Application’ solution. The query
was customized to display both incoming & outgoing relationships till 2nd level.
Figure 8: Class diagram after Show Related Elements
3.2.3 Visualizing types from .Net Assemblies
You can also visualize the types from .Net Assemblies in similar way it was done
for Visual Basic code elements and use Show Related Elements option.
Author: Manish (Manish Paul/India/IBM)
Figure 9: .Net assembly type visualized in Class Diagram
3.2.4 Preference options for visualizing types from .Net Assembly
You set preference options for visualization of types from .Net Assembly using
Windows->Preference->.Net Modeling preference page:
Figure 10: Preferences page to set relationship options for elements
visualized from a Visual Basic file.
Author: Manish (Manish Paul/India/IBM)
Also of note is the .NET Show Related Elements Filters Preferences page, as
shown in figure 11.
Figure 11: Show Related Elements dialog for .NET elements
3.3 Visualizing to Topic and Browse Diagram
As mentioned previously, the Visualize menu allows you to explore .NET elements in a
Browse diagram. Figure 12 illustrates a Browse diagram, which is a temporary, noneditable diagram that provides a quick way to explore existing elements and their
relationships. Browse Diagrams are a nice way to walk through a code base in order to
understand its structure and the nature of its interdependencies.
The toolbar panel at top allows you to set the criteria for displaying related elements in
Browse Diagram and on applying the selected options Browse Diagram is refreshed.
Author: Manish (Manish Paul/India/IBM)
Figure 12: Browse Diagram
A Topic diagram can be used to quickly create dynamic views of relationships between
.NET elements. Figure 13 shows the predefined queries that the Topic wizard provides so
that you can view the relationships.
Author: Manish (Manish Paul/India/IBM)
Figure 13: Topic diagram presets
Topic diagrams -- like Browse diagrams -- are query-driven and cannot be edited, but you
can customize the query (which causes the diagram to refresh). You can also just refresh
the diagram to cause code changes to be reflected on it.
4. Using Viz Element in UML Models
A visualized element can be used in UML models in similar way UML elements are
used. UML-to-Visual Basic transformation will not update the corresponding code for
visualized elements.
For example Figure 14. Illustrates a scenario where in UML Class element
‘SpecialAccount’ is implementing the visualized interface ‘IAccount’.
Author: Manish (Manish Paul/India/IBM)
Figure 14: Using visualized element in UML model
Download