Visualize with Rational Application Developer

A tour of Rational Application Developer's visual diagramming tools

Rational Application Developer provides visual diagramming tools to help you gain insight and knowledge of existing applications or to more easily create and understand new applications. After completing this tutorial, you will know how to create class, sequence, browse, and topic diagrams.

Eric Long is a Software Engineer in the IBM Developer Skills Program. Eric graduated from The University of Texas with a degree in Computer Science. He joined IBM in July of 2004 and currently works in Austin, Texas. As a Software Engineer, he provides technical information to developers on open source and industry trends and technologies through speaking engagements, Web content, and faculty consultations at IBM Academic Initiative member universities. His work also includes technical demos and content available at www.ibm.com/university.

Before you start

Rational Application Developer provides diagrams which enable you to view code from different perspectives using UML 2.0 notation. These diagrams are referred to as UML visualization, not to be confused with UML Modeling. All UML visualizations in Rational Application Developer are synchronized with a source file. Modifications to the source file will dynamically change the diagram and vice versa. To create UML 2.0 models, you need to use Rational Software Modeler or Rational Software Architect. Stay tuned to developerworks for future tutorials covering the visual capabilities of both of those products.

About this tutorial

This tutorial introduces you to the process of creating UML and non-UML diagrams using Rational Application Developer. This tutorial demonstrates the following Rational Application Developer diagrams:

Class diagrams

Sequence diagrams

Browse diagrams

Topic diagrams

Note:Rational Application Developer can be used to diagram more than just Java classes in class diagrams. Database components can also be diagramed. However, this tutorial does not cover that. For more information on diagramming database components, see the Resources section.

This tutorial is written for developers who are interested in learning about Rational Application Developer's visualization capabilities.

Objectives

After completing this tutorial, you will know how to use Rational Application Developer to create class, sequence, browse, and topic diagrams.

Prerequisites

This tutorials assumes that you have a solid understanding of Java programming. Knowledge of UML 2.0 diagrams is helpful, but not required.

System requirements

To run the examples as demonstrated in this tutorial, you need to have Rational Application Developer installed on your machine.

If you don't already have a copy of Rational Application Developer, you can download a free trial version. All of the prerequisites for Rational Application Developer are located in the Resources section of this tutorial.

Create a Java project and package

To get started with this tutorial, you need to do some initial set up. First, create a Java project to hold all of the different elements you will be creating (i.e. packages, Java classes, diagrams, etc.).

Create a Java project

Creating a Java project is very easy:

Open Rational Application Developer.

To open the Java perspective, from the Window menu, select Open Perspective > Java.

Make sure all of your open projects are closed.

From the File menu, select New > Project.

Make sure the Show All Wizards box is checked.

Expand the Java folder.

Select Java Project.

Figure 1. The New Project window

Fill in the Create a Java project wizard as follows:

Project Name: IBMPayroll

Location: Create project in workspace.

Project layout: Use project folder as root for sources and class files.

The wizard should look like this:

Figure 2. The New Java Project window

Click Finish.

Now, create a package to house your Java classes.

Create a package

In the Package Explorer view, right-click the newly created IBMPayroll project.

Select New > Package.

Figure 3. New Package

In the New Java Package window, name the package com.ibm.common.

Click Finish.

The Package Explorer should now look like this:

Figure 4. Package Explorer view

Now on to the more exciting part of the tutorial. Let's move on to UML class diagrams.

Figure 17. Final class diagram

Visualize a method using a sequence diagram

Now that a UML class diagram has been created, you are going to utilize another visualization capability that Rational Application Developer offers: sequence diagrams. A sequence diagram shows the sequence (in time) of messages, which are exchanged among roles that implement the behavior of the system. This section of the tutorial guides you through the process of creating a sequence diagram using Rational Application Developer.

Figure 20. Sequence diagram

Figure 21. Diagram outline view

Create a topic diagram from existing code

A topic diagram is a non-editable diagram that provides a quick way to show relationships between elements. They are useful to define a query and to display and persist the results from that query. An example would be creating a hierarchy topic diagram that you can update to always show the hierarchy for a specific class. This section of the tutorial shows you how to use Rational Application Developer to create a topic diagram from existing code.

Create a topic diagram

From the Package Explorer view, right-click the Employee class.

Figure 22. Employee class

Select Visualize > Add New Diagram File > Topic Diagram...

Figure 23. Select new topic diagram

Fill in the Topic Wizard window as follows:

Parent Folder: IBMPayroll/com/ibm/common

File name: EmployeeTopicDiagram

The wizard should now look like this:

Figure 24. Topic Wizard

Click Next.

Select Java Field Types as the topic.

Figure 25. Topic Wizard

Use the defaults for the remaining pages, however feel free to explore the options.

Click Finish.

The finished browse diagram looks like this:

Figure 26. Browse diagram

Create a browse diagram

A browse diagram is a temporary, non-editable diagram that shows the results of a query on a context diagram element in a model. Use browse diagrams to navigate through a model to view the details of its elements and relationships. For example, create a browse diagram to show a dynamic view of a class and its related elements to understand how it fits into the model.

Create a browse diagram

From the Package Explorer view, right-click the Employee class.

Figure 27. Employee class

Select Visualize > Explore in Browse Diagram...

Figure 28. Select Explore in Browse Diagram

The diagram is automatically created.

Click all of the buttons in the editor to explore all relationships to the Employee class.

Figure 29. Select all Relationships

Click Apply.

The final diagram looks like this:

Figure 30. Final browse diagram

Conclusion

Congratulations! In this tutorial, you covered the creation of a class, sequence, browse, and topic diagram to create and visualize a single Java class. Visual diagramming is far more useful when trying to understand and edit larger applications. With the knowledge you've gained from this tutorial, you can easily move on and apply the same skills to complex applications using Rational Application Developer.

The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.