You are on page 1of 44

This project will allow you to test drive Rational Rose 98i by building a model of a Course Registration System

for a
University. The Visual Basic programming language is used in this demo.

Requirements:
Rational Rose
Visual Basic 6.0
Setup:

1. Start Rational Rose


If you are using Rose Enterprise, do not use
a Framework (hit Cancel button on the Framework
Wizard).

2. Set the default language to Visual


Basic Tools:Options menu
command Notation tab
Default language field (select the arrow to
make the drop down menu visible and select
Visual Basic)

3. Turn off focus of control


Tools:Options menu
command Diagram tab
Focus of Control checkbox
4. Display all attributes and operations
Tools:Options menu
command Diagram tab
Show all Attributes and Show all
Operations checkboxes

5. Display sequence diagram


numbering Tools:Options
menu command Diagram tab
Sequence numbering checkbox

We will start modeling the Course Registration Problem by


creating a Use Case Diagram. This type of diagram consists
of actors, use cases and the relationships between them.
Let's open the Main Use Case Diagram.

Main Case Use Diagram

1. Click the + next to the Use Case View package in the


Browser.
2. Double-click on the diagram called Main to open
the diagram.

The first step is to identify the actors where an actor is


someone or some thing that interacts with the system under
development. For our problem we have identified 4 actors -
the Student, the Professor, the Registrar and the Billing
System.
Four Actors

1. Click to select the actor icon from the tool bar


(stickman).
2. Click on the diagram to place the actor.
3. While the actor is still selected, enter the name Student.
4. Repeat the above steps for the other three actors
(Professor, Registrar and Billing System).

Next, we identify use cases for each of our actors. A use


case is a piece of functionality that is provided by the
system. You can identify uses cases by looking at each actor
and seeing how the actor interacts with the system. In our
model, the Student wants to Register for Courses. The
Billing System receives registration information. The
Professor wants to Request a Course Roster. Finally, the
Registrar must Manage the Curriculum.

Use Cases for the Actors


1. Click to select the use case icon from the toolbar (oval).
2. Click on the diagram to place the use case.
3. While the use case is still selected, enter the name
Register for Courses.
4. Repeat the above steps for the other use
cases. (Request Course Roster, Manage
Curriculum).

Relationships are drawn between the actors and the use


cases. A uni-directional arrow is used to show the direction of
the communication (who initiates the communication). In the
Course Registration system, the Student initiates the Register
for Courses use case, which in turn communicates, with the
Billing System. The Professor initiates the Request Course
Roster use case. The Registrar initiates the Manage
Curriculum use case.

Relationships Between the Actors and Use Cases

1. Click to select the uni-directional association icon


from the toolbar (arrow).
2. Click on the Student actor and drag the line to the
Register for Courses use case.
3. Click to select the uni-directional association icon
from the toolbar.
4. Click on the Register for Courses use case and drag
the association line to the Billing System actor.
5. Repeat the above steps for the other relationships
(Professor actor to Request Course Roster use
case and Registrar actor to Manage Curriculum use
case).

NOTE: If you depress the Shift key prior to selecting the


uni-directional arrow, you do not have to keep re-selecting
it from the Toolbar.

Use case functionality may be graphically shown in a


Sequence Diagram. This diagram is one path through the flow
of events for the use case - for example, adding a student to
a course.
Sequence diagrams contain objects and messages between the
objects that show how the behavior is realized. Let's look at
the "Add a Course" sequence diagram for the "Register for
Courses" use case.

Add a Course Sequence Diagram

1. Click-right on the Register for Courses use case in the


Browser to make the short cut menu visible.
2. Select the New:Sequence Diagram menu command.
This will add a sequence diagram called New Diagram
to the Browser.
3. While the new diagram is still selected, enter the name
Add a Course.

We will then add the objects and messages to the diagram to


carry out the needed functionality. We open the diagram by
double-clicking on the diagram in the Browser. Since this
scenario is initiated by the Student actor, we can drag the
actor onto the diagram. The actor may be named if this is
needed to add clarity to the drawing. We'll call our student
"Joe".
Sequence Diagram - Joe

1. Double-click on the sequence diagram in the Browser


to open the diagram.
2. Click to select the Student actor in the Browser and
drag it onto the sequence diagram.
3. Click to select the actor on the sequence diagram
and enter its name - Joe.

In this scenario, the student must fill in information on a


registration form and then the form is submitted. This
implies that there is a registration form object, which
receives information from the student. We will create the
form and add two messages, "fill in info" and "submit".

Sequence Diagram - Registration Form Object

1. Click to select the object icon from the toolbar


(rectangle).
2. Click on the sequence diagram to place the object.
3. While the object is still selected enter the
name registration form.
4. Click to select object message icon from the toolbar
(arrow).
5. Click on the dashed line for the Student actor and
drag the arrow to the dashed line for the registration
form object.
6. While the arrow is still selected, enter the
following message: fill in information.
7. Repeat steps 4 through 6 to create the submit message.

The form then sends a message to the manager. It tells the


manager that a student must be added to a course - Joe
wants
to take math 101.

Sequence Diagram - Manager

1. Click to select the object icon from the toolbar


(rectangle).
2. Click on the sequence diagram to place the object.
3. While the object is still selected enter the name
manager.
4. Click to select object message icon from the toolbar
(arrow).
5. Click on the dashed line for the registration form
object and drag the arrow to the dashed line for the
manager object.
6. While the arrow is still selected, enter the
following message: add Joe to Math 101.

The manager in turn tells math 101 that Joe would like to
be added to the course.
Sequence Diagram - Math 101

1. Click to select the object icon from the toolbar


(rectangle).
2. Click on the sequence diagram to place the object.
3. While the object is still selected enter the name math
101.
4. Click to select object message icon from the toolbar
(arrow).
5. Click on the dashed line for the manager object and
drag the arrow to the dashed line for the math 101
object.
6. While the arrow is still selected, enter the
following message: add Joe.

The course in turn, asks the course offering if it is open (in


this scenario, the answer is yes) so it tells the offering to add
Joe.

Sequence Diagram - Section 1

1. Click to select the object icon from the toolbar


(rectangle).
2. Click on the sequence diagram to place the object.
3. While the object is still selected enter the name section
1.
4. Click to select object message icon from the toolbar
(arrow).
5. Click on the dashed line for the math 101 object and
drag the arrow to the dashed line for the section 1
object.
6. While the arrow is still selected, enter the
following message: accepting students?
7. Repeat steps 4 through 6 to create the message add
Joe.

Finally, the billing system is notified that Joe is taking math 101.
Sequence Diagram - Billing System Notified

1. Click to select the object icon from the toolbar


(rectangle).
2. Click on the sequence diagram to place the object.
3. While the object is still selected enter the name bill.
4. Click to select object message icon from the toolbar
(arrow).
5. Click on the dashed line for the manager object and
drag the arrow to the dashed line for the bill object.
6. While the arrow is still selected, enter the
following message: Send bill for Math 101 to Joe.

The objects in the sequence diagrams are grouped into


classes. A class is a template for creating objects just like a
cookie
cutter is used to create cookies. Based on our sequence
diagram we can identify the following objects and
classes:

registration form is an object in the RegForm


class manager is an object in the Manager class
math 101 is an object in the Course class
section 1 is an object in the CourseOffering class
bill is the interface to the external billing system, so
we will use BillingSystem as the name of its class.

Classes are created in the Logical View of the tool.


Logical View

1. Click-right on the Logical View package in the Browser


to make the shortcut menu visible.
2. Select the New:Class menu command. This will add
a class called NewClass to the Browser.
3. While the class is still selected, enter the name
RegForm.
4. Repeat the above steps for the additional classes:
Manager, Course, CourseOffering and BillingSystem

As classes are created, they should be documented.


Documentation is added via the Documentation
Window.

Documentation Window

1. Click to select the CourseOffering class in the Browser.


2. Enter its documentation in the Documentation Window.

The process of diagramming scenarios and finding classes


continues until you reach the law of diminishing returns
which says that you are not finding out any new information
- that is, you are not finding out any new classes and you
seem to be typing the same messages over and over.
A Browser view of the classes is good but a picture is also
needed. That is where class diagrams come into play.
Let's open the Main class diagram and add our classes to
it.
Main Class Diagram

1. Double-click on the diagram called Main in the


Browser to open the diagram.
2. Select the Query:Add Classes menu command.
3. Select the All >> button to add all the classes.
4. Click the OK button to close the window and add
the classes to the diagram.
5. Re-arrange the classes on the diagram as needed
by selecting the class and dragging it to its new
location.

NOTE: Classes can also be added to the diagram by dragging


them from the Browser onto the diagram. This can only be
done for one class at a time.

The UML has a concept of a stereotype, which may be used


to create new types of modeling elements. This provides the
capability to add meaning to a model. We will use the
pre-defined stereotype of Interface for the BillingSystem
class since this is the class that is the interface to the
external billing system. We will use the stereotype of Form
for the RegForm class since this will eventually be some sort
of GUI form.
Billing System Class

1. Double-click on the BillingSystem class on the Main


class diagram to make the Specification visible.
2. Click the arrow in the Stereotype field to make the
drop down menu visible.
3. Select the Interface stereotype.
4. Click the OK button to close the Specification.
5. Repeat the process for the RegForm class and use
the stereotype Form.

Relationships between classes are added to facilitate object


communication. Sequence diagrams are examined to see
what objects must talk to one another. If objects must talk
then there must be a pathway for communication between
their classes. Two common types of relationships are
associations and aggregations.

An association is a connection between classes. By examining


the "Add a Course" sequence diagram we can determine that
the following associations exist: RegForm to Manager,
Manager to Course and Manager to Bill.

Associations

1. Click to select the unidirectional association icon from


the toolbar (line).
2. Click on the RegForm class and drag the association
line to the Manager class.
3. Repeat the above steps for the following relationships:
Manager to Course
Manager to BillingSystem.

An aggregation is a stronger form of association. It shows


the relationship between a whole and its parts. We will
create an
aggregation relationship between the Course and
the CourseOffering classes (a Course is comprised
of CourseOfferings).

Associations

1. Click to select the aggregation icon from the toolbar


(line with a diamond).
2. Click to select the class representing the whole - Course.
3. Drag the aggregation line to the class representing
the part - CourseOffering.

Multiplicity indicators are added to the relationships in the


model to show "how many" objects participate in the
relationship.
Multiplicity

1. Click-right on the aggregation line near the


CourseOffering class.
2. Select the Multiplicity:One or More menu command.
3. Click-right on the aggregation line near the Course class.
4. Select the Multipliciy:1 menu command.

The structure of a class is represented by its set of attributes.


Structure is found by examining the problem requirements
and through conversions with domain experts and customers.
In our model, each CourseOffering is held at a specific
location - this is an attribute.

Attributes

1. Click-right on the CourseOffering class on the


class diagram.
2. Select the New:Attribute menu command. This will
add an attribute called <<>>name to the class.
3. While the new attribute is still selected, enter its name -
location.

The behavior of a class is represented by its set of


operations. Operations are initially discovered by mapping the
messages in sequence diagrams to operations.

The first step is to assign the objects in the sequence


diagram to classes.
Assign Objects to
Classes

1. Open the Add a Course sequence diagram by double


clicking on the diagram in the Browser.
2. Click to select the CourseOffering class in the Browser.
3. Drag the CourseOffering class onto the section 1 object.

Once an object is mapped to a class, you can map the


messages it receives to new operations, or to operations
that have already been defined for the class.

New Operation

1. Click-right on the "accepting students ?" message


to make the shortcut menu visible.
2. Select the <new operation> menu command to make the
Operation Specification visible.
3. Enter the name of the new operation - offeringOpen.
4. Click the OK button to close the Operation specification.

Once a new operation has been created, messages may


be mapped to the operation.
Mapping Messages

1. Click-right on the "accepting students?" message


to make the shortcut menu visible.
2. Select the offeringOpen() operation.

Eventually, you reach a point where it is time to generate code


for the classes in the model. Here, we use the Component
View of the tool to specify the components in our system.
Rose automatically creates one component diagram called
Main.

Component Diagram - Main

1. Click the + next to the Component View package in the


Browser to expand the package.
2. Double-click on the diagram called Main to open the
main component diagram.

In our model, we will create two components - Registration and


BillingSystem.
Components - Registration and BillingSystem

1. Click to select the component icon from the toolbar.


2. Click on the diagram to place the component.
3. While the new component is still selected, enter its name
-- Registration. (You will have to re-size this component).
4. Repeat the above steps and create the BillingSystem
component.

Each component is assigned a language. This implies that all


classes assigned to the component will be implemented in the
assigned language. We will assign the BillingSystem
component to Visual C++ and the Registration component to
Visual Basic.

Assigning Languages

1. Double-click on the BillingSystem component on


the component diagram or in the Browser to make
the Component Specification visible.
2. Click the arrow in the Language field to make the
drop down menu visible.
3. Select the desired language - VC++.
4. Click the OK button to close the Specification.
5. Double-click on the Registration component and show
that the Language is set to Visual Basic. Rose does
this since the default language was set to Visual
Basic.

Once components are created, classes in the model must


be assigned to the component.
Assigning Classes

1. Double-click on the BilllingSystem component on


the diagram or in the Browser to make the
Specification visible.
2. Select the Realizes tab.
3. Click-right on the BillingSystem class to make
the shortcut menu visible.
4. Select the Assign menu command.
5. Click the OK button to close the Specification.
6. Assign all the other classes to the
Registration component.

Since the BillingSystem class is an Interface class it is


drawn using lollypop notation.
BillingSystem Class

Relationships between components are shown using a


dependency relationship. In our model, the Registration
component "talks" to the BillingSystem component via
the
BillingSystem interface.

Dependency Relationship

1. Click to select the Dependency Relationship icon


from the toolbar.
2. Click on the Registration component and drag the
arrow to the BillingSystem component.

Save the model.

We will generate the code for the Registration component.


Since the component is mapped to the Visual Basic
Language we will use the Tools:Visual Basic:Generate Code
menu command to generate the code.
Generating the Code

1. Click to select the Registration component on the


component diagram.
2. Select the Tools:Visual Basic:Update Code
menu command.

This brings up the Visual Basic Code Update Tool. In this


demo, we will accept all the code generation defaults,
therefore we can just select the Finish button.

Visual Basic Code Update Tool

1. Click the Finish button to accept all the code


generation defaults.

The code generator will create a standard VB project called


Registration. In Visual Basic, a standard project is created
with one form called Form1. The Rose code generation
wizard detects that this form is in the Visual Basic code but
not in the model and you are asked if you want to keep the
class or delete it. We can delete it.
Code Generation Wizard

1. Click to select the Form1 class in the right list.


2. Click the OK button to continue the code
generation process.

When code generation is completed, the Summary window


is displayed. All errors are written to the log.

Summary Window

1. Click the Close button to complete the code


generation process.

Let's look at the code generated by Rose.


Rose-generated Code

1. Click to select the Registration component on


the component diagram.
2. Select the Tools:Visual Basic: Browse Source Code
menu command.

You will notice that Rose generated code for all the
classes assigned to the Registration component.

Rose-generated Code - Registration

Rose even generated a form for the RegForm class. This is


due to the fact that the VB code generation process realizes
that classes with a stereotype of Form are special types of
Visual Basic classes.
Rose-generated Form

You will notice that the documentation that was added to


the model is also added to the code.
Documentation

Now comes the 1000-dollar question. You have done your


analysis and design, generated the code and are
implementing the methods when you discover that you need
another operation. How many folks will go back to the model,
add the operation and re-generate the code? Probably no one
- you will update the code!

Add Procedure

1. Select the CourseOffering course in Visual Basic.


2. Select the Tools:Add Procedure menu command.
3. Enter the name of the new procedure - incrementCount.
4. Select the Function radio button.
5. Click the OK button to close the Add Procedure window.

We now have a problem, our code says one thing and our
model says another thing. This is where reverse
engineering comes into play.
Reverse Engineering

1. In Visual Basic, click right on the Rose model in the Rose


98I window.
2. Select the Update Model menu command.

Since we only updated the CourseOffering class, that is the


only class we need to reverse.

click to enlarge

Reverse CourseOffering

1. Click the + next to the Registration project to expand


the project.
2. Click the checkbox next to all classes except
the
CourseOffering class to de-select the classes.
3. We will use the tool defaults and select the Finish
button to complete the reverse engineering process.

The Summary window is displayed at the end of the


reverse engineering process. All errors are written to the
Log.
Summary Window

1. Click the Close button to complete the


reverse engineering process.

Let's look at the class diagram to see how our model has
been updated.

Class Diagram

1. If the Logical View package is not expanded, click the +


to expand the package.
2. Double-click on the Main class diagram in the Browser
to open the diagram.
3. Re-arrange the classes as needed by selecting the
class and dragging it to a new location.
4. You will notice that the operation we added in Visual
Basic for the CourseOffering class (incrementCount)
has been added to the model.
5. You will also notice that a package called Debug
has also been added. Let's look at that package.

If you expand the Debug package in the Browser, you will


see that it contains two classes. These classes were added
automatically by Rose when the code was generated.

Debug Package

1. Click the + next to the Debug package in the Browser


to expand the tree. This package contains classes
automatically added to the model when the default
code generation options were selected.

In this short demo, you have seen how Rational Rose and
Visual Basic may be used throughout the analysis and design
phases of development to visualize, analyze, design,
implement, and document a system under development.

You might also like