Rational Rose Demo Tutorial

advertisement
Text
Rational Rose Enterprise Steps
When you start Rational Rose Enterprise you will
notice that there are four views that make up a Rose
model – the Use Case View, the Logical View, the
Component View and the Deployment View.
We will start by creating the Main Use Case
Diagram in the Use Case View of the model.
1.
2.
Click the + next to the Use Case View in the
Browser to expand the view.
Double-click on the diagram called Main.
A Use Case Diagram consists of actors, use cases
and the relationships between them. 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
1.
Next, use cases for each of the actors are identified.
A use case is a piece of functionality that is
provided by 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.
1.
Text
Rational Rose Enterprise Steps
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
a Course Roster use case. The Registrar initiates the
Manage Curriculum use case.
1.
2.
3.
4.
2.
3.
4.
2.
3.
4.
5.
A Sequence Diagram is a realization of a use case.
It is typically one path through the flow of events for
the use case. Sequence diagrams contain objects
and messages between the objects that show how the
behavior is realized. We will look at adding Math
101 (a Course) for Joe (a Student actor).
1.
2.
3.
Click to select the actor icon from the tool bar
(stickman).
Click on the diagram to place the actor.
While the actor is still selected, enter the name
Student.
Repeat the above steps for the other three
actors.
Click to select the use case icon from the
toolbar (oval).
Click on the diagram to place the use case.
While the use case is still selected, enter the
name Register for Courses.
Repeat the above steps for the other use cases.
Click to select the uni-directional association
icon from the toolbar (solid line with arrow).
Click on the Student actor and drag the line to
the Register for Courses use cases.
Click to select the uni-directional association
icon from the toolbar.
Click on the Register for Courses use case and
drag the association line to the Billing System
actor.
Repeat the above steps for the other
relationships.
Click-right on the Register for Courses use case
in the Browser to make the short cut menu
visible.
Select the New:Sequence Diagram menu
choice. This will add a sequence diagram
called New Diagram to the browser.
While the new diagram is still selected, enter
4.
Since this sequence diagram is started by the
Student actor named Joe, the actor must be added to
the diagram.
1.
The next step is to identify the objects that must
interact to carry out the identified behavior. Here
we have the following objects: Registration Form,
the manager, math 101, and section 1.
1.
2.
2.
3.
4.
the name Add a Course.
Double-click on the new sequence diagram to
open the diagram.
Click to select the Student actor from the
browser and drag it onto the sequence diagram.
While the actor is still selected, enter Joe (the
name of the actor).
Click to select the object icon from the toolbar
(rectangle).
Click on the sequence diagram to place the
object.
While the object is still selected enter the name
Registration Form.
Repeat the above steps for the other identified
objects.
Messages are added to the sequence diagram to
show the behavior needed to carry out the identified
functionality. In our model:
The student fills out the information on the
Registration Form and submits the form.
The form tells the manager that it needs to add a
course called Math 101 for Joe.
The manager tells math 101 to add Joe.
Math 101 asks section 1 if it is accepting students
(in this scenario, the answer is yes).
Math 101 tells section 1 to add Joe.
1.
Text
Rational Rose Enterprise Steps
Sequence diagrams are used to find the objects
needed in the system. Since there are many objects
in any system, they are grouped into classes. A
class is a collection of objects with the same
structure, the same behavior, the same relationships
and the same meaning. Classes are contained in the
Logical View of the model and shown on Class
diagrams.
1.
Based on the information in our sequence diagram
we can identify the following classes:
RegistrationForm, Manager, Course,
CourseOffering and StudentInformation.
1.
2.
3.
4.
2.
2.
3.
4.
As a class is created, it should be documented. The
documentation should state why the class is part of
1.
Click to select object message icon from the
toolbar (arrow).
Click on the dashed line for the Student actor
and drag the arrow to the dashed line for the
Registration Form.
While the arrow is still selected, enter the
following message: fill in information.
Repeat the above steps for:
Student to Registration Form: submit
Registration Form to manager:
add course(joe, math 101)
manager to math 101: add (joe)
math 101 to section 1: accepting students ?
math 101 to section 1: add (joe)
Click the + next to the Logical View in the
browser to expand the view.
Double-click on the diagram called Main.
Click to select the class icon from the toolbar
(compartmented rectangle).
Click on the class diagram to place the class.
While the class is still selected, enter
RegistrationForm.
Repeat the above steps for the other identified
classes.
If the documentation window is not visible,
select the View:Documentation Window menu
the model. The documentation for a class is
contained in the Documentation window.
2.
choice to make the window visible.
Click to select the CourseOffering class and
enter the following documentation: an offering
by the university for a given semester.
In our model, if more sequence diagrams were
created you would find a ProfessorInformation
class, a BillingSystem class and possibly a
ScheduleAlgorithm class.
1.
Add these classes to the class diagram.
The structure of a class is represented by its set of
attributes.
1.
Right-click on the CourseOffering class in the
Browser to make the shortcut menu visible.
Select the New:Attribute menu choice. This
will add an attribute called name to the class.
While the new attribute is still selected, enter its
name -- location.
Repeat the above process and add the following
attributes:
StudentInformation class: name, major
ProfessorInformation class: name, department.
2.
3.
4.
5.
6.
Text
Rational Rose Enterprise Steps
The behavior of a class is represented by its set of
operations.
Although behavior may be added to a class on the
logical view it is typically added via a sequence
diagram since these diagrams depict what behavior
an object should have.
1.
2.
3.
4.
5.
6.
7.
Click the + next to the Use Case View in the
browser to expand the view.
Click the + next to the Register for Courses use
case to expand the use case.
Double-click on the Add a Course sequence
diagram to open the diagram.
Click to select the CourseOffering class in the
Logical View of the browser and drag the class
on the section 1 object. This assigns the object
to the class.
Right-click on the accepting students ? message
to make the shortcut menu visible.
Select the <new operation> menu choice to
make the Operation Specification visible.
Enter the name of the new operation: open.
8.
9.
Click the OK button to close the specification.
Right-click on the accepting students ? message
to make the shortcut menu visible.
10. Select the open operation to map the message to
the newly created operation.
11. When you expand the CourseOffering class in
the browser by clicking the + next to the class
in the browser, you will notice that the
operation is added to the class.
The structure and/or behavior of a class may be
displayed on a class diagram.
1.
2.
3.
4.
Click right on the CourseOffering class in the
Logical View/Main Class diagram to make the
shortcut menu visible.
Select the Options: Show All Attributes menu
command.
Click-right on the CourseOffering class to make
the shortcut menu visible.
Select the Options: Show All Operations menu
command.
Relationships between classes allow the objects in
the classes to communicate. Four common types of
relationships are association, aggregation,
dependency and generalization.
1. Save your model to CourseRegistration.mdl
Text
Rational Rose Enterprise Steps
An association is a bi-directional structural
connection between classes. An association is
shown as a line connecting the related classes.
1.
The association between the RegistrationForm class
to the Manager class means that objects in the
RegistrationForm class know objects in the Manager
class and vice versa.
3.
An aggregation is a stronger form of an association
– it is a relationship between a whole and its parts.
An aggregation is shown as a line with a diamond
next to the class representing the whole.
1.
2.
4.
2.
3.
Double click on the Main class diagram in the
Logical view to open the diagram.
Click to select the association icon from the
toolbar (line).
Click on the RegistrationForm class and drag
the association line to the Manager class.
Repeat the above steps for the following
relationships:
Manager and Course,
Manager and BillingSystem,
CourseOffering and StudentInformation, and
CourseOffering and ProfessorInformation.
Click to select the aggregation icon from the
toolbar (line with a diamond).
Click to select the class representing the part –
CourseOffering.
Drag the aggregation line to the class
representing the whole – Course.
This is read as: A Course contains or has
CourseOfferings.
A dependency relationships is a client supplier
relationship where the client needs the services of
the supplier but the client does not know the
supplier – something else in the system tells the
client to use the supplier. This type of relationship
is shown as a dashed arrow pointing from the client
to the supplier.
This is read as: A Manager uses a
ScheduleAlgorithm.
1.
You will notice that both the ProfessorInformation
class and the StudentInformation class deal with
information about registration system users. They
also have the attribute called name in common.
Here, generalization may be used to create a
superclass called Registration user to hold the
common structure and behavior.
1.
2.
3.
2.
3.
4.
5.
As superclass/subclass relationships are created,
common structure/behavior is moved to the
superclass.
1.
2.
3.
4.
5.
6.
Click to select the dependency relationship
from the toolbar (dashed arrow).
Click on the class representing the client –
Manager.
Drag the dependency relationship to the class
representing the supplier – ScheduleAlgorithm.
Add the superclass (RegistrationUser) to the
class diagram.
Click to select the generalization icon from the
toolbar (line with a hollow triangle).
Click on the subclass – StudentInformation.
Drag the generalization line to the super class –
RegistrationUser.
Repeat steps 2 – 4 for the ProfessorInformation
class.
Click the + next to the StudentInformation class
in the browser to expand the class.
Click to select the name attribute.
Drag the name attribute to the RegistrationUser
class.
Click the + next to the ProfessorInformation
class in the browser to expand the class.
Right-click to select the name attribute and
make the shortcut menu visible.
Select the Delete menu command.
Text
Rational Rose Enterprise Steps
The UML has a concept called a stereotype which
allows the user to extend the UML notation to add
meaning for the application. Some common
stereotypes for classes are interface, entity, and
control.
1.
2.
3.
4.
Double click on the BillingSystem class to
make the Specification visible.
Click the arrow in the Stereotype field to make
the drop down menu visible.
Select Interface.
Click the OK button to close the specification.
You can also create your own stereotypes – you do
not have to use only the pre-defined ones.
Next, design details are added to the classes. Things
like association navigation,
Data types for attributes and operation signatures.
1.
2.
Right click on the aggregation line near the
diamond head to make the shortcut menu
visible.
Select the Navigation menu command to turn
off navigation. This will add an arrow near the
CourseOffering class. This implies that the
Course can talk to the CourseOffering but the
CourseOffering cannot talk to the Course.
3.
4.
5.
6.
7.
8.
The next diagram supported by Rational Rose
Enterprise is the Component diagram. Here, you
can visualize the various components in your
system.
1.
A component may be a source code component, a
library component or an executable component.
1.
2.
2.
3.
4.
5.
6.
7.
8.
9.
Double click on the CourseOffering class to
make the Specification visible.
Select the Attributes tab.
Enter the data type for the location attribute
(char*).
Select the Operations tab.
Enter the Return class for the open operation
(int).
Click the OK button to close the Specification.
Click the + next to the Component View in the
browser to expand the view.
Double click on the diagram called Main.
Click to select the component icon from the
toolbar (
Click on the diagram to place the component.
While the new component is still selected, enter
its name (registration.exe).
Click to select the component icon from the
toolbar.
Click on the diagram to place the component.
While the new component is still selected, enter
its name (CourseOffering).
Click to select the component icon from the
toolbar.
Click on the diagram to place the component.
While the new component is still selected, enter
its name (BillingSystem).
Text
Rational Rose Enterprise Steps
Once the components are created, the classes in the
logical view are assigned to the components.
1.
2.
3.
4.
5.
6.
The next step is to add dependencies between the
components which are shown as dashed arrows.
1.
2.
Double-click on the CourseOffering component
to make the Specification visible.
Select the Realizes tab. You will see a list of
classes in the model.
Right-click on the CourseOffering class to
assign the class to the component.
Double click on the BillingSystem component
to make the Specification visible.
Select the Realizes tab.
Right-click on the BillingSystem interface class
to assign the class to the component. You will
notice that a circle called BillingSystem is
added to the BillingSystem component. This is
the UML notation for an interface.
Click to select the dependency relationship icon
from the toolbar.
Click on the Registration.exe component and
drag the arrow to the CourseOffering
3.
4.
Next we will set the language for each component.
1.
2.
3.
4.
5.
6.
7.
Code generation is done using the Tools menu.
1.
2.
3.
Next we will generate the Java code.
1.
2.
3.
components.
Click to select the dependency relationship icon
from the toolbar.
Click on the Registration.exe component and
drag the arrow to the BillingSystem interface
(circle).
Double-click on the CourseOffering component
to make the Specification visible.
Click on the arrow in the Language field to
make the drop down menu visible.
Select C++.
Set the Stereotype to be Subprogram Spec,
since you intend to generate code for it.
Double-click on the BillingSystem component
to make the Specification visible.
Click on the arrow in the Language field to
make the drop down menu visible.
Select Java.
Select the CourseOffering component
Select the Tools:C++: Code Generation menu
command.
When the code is generated select the
Tools:C++:Browse Header menu command to
view the code.
Select the BillingSystem component.
Select the Tools:Java:Generate Java menu
command.
When the code is generated select the
Tools:Java:Browse Java Source menu
command to view the code.
Text
Rational Rose Enterprise Steps
You have done your analysis and design and
generated the code and are implementing the
methods when you realize that you forgot an
attribute. The attribute is added directly to the code.
1.
Add the attribute salary with a data type of
double to the code for the CourseOffering class
You now have a problem. The code and the model
do not match.!! This is where the C++ Analyzer
may be used to update the model
1.
Select the Tools:C++ :Reverse Engineering
menu command
To create a new analyzer project that uses the
default settings, depress the Shift key and select
the File:New menu command.
You need to tell the analyzer where the source code
is located
1.
2.
Select the directories button
Select the directories, and the sub directories
where you have your project source code.
Next, the files to be analyzed are added to the
1.
Select the files button, and for each directory ,
2.
project.
add the files you wish to have analyzed.
The Code Cycle menu command is used to analyze a
file and insert any code generation markers that
Rose needs.
1.
Finally, the reverse engineered information is
exported to Rose.
1.
2.
3.
2.
3.
4.
The analyzed information is imported into Rose.
1.
2.
When the files have been added, do a
Edit:Select All option to select all the files.
Select Actions: CodeCycle.
If a file reports an error, double click on that
file in the file list, to see the errors. Double
clicking on the error itself will take you to the
error location in the code file.
To export the reverse engineered information to
Rose, do Actions:Export to Rose.
In the dialog that comes up, choose the option
Reverse Engineered.
You can also dictate which directory you wish
to have your reverse engineered model
generated to.
Press OK, when you have set all the choices.
Check the log to make sure that the model was
correctly reverse engineered.
The log will also inform you of the number of
classes, relationships etc that were exported.
Text
Rational Rose Enterprise Steps
The last diagram in Rational Rose Enterprise is the
Deployment diagram. There is only one deployment
diagram per model. It shows the hardware and the
connections between the hardware for the system
under development.
1.
2.
3.
4.
5.
6.
7.
3.
In this short demo, you have seen how Rational
Double-click on the Deployment Diagram in the
browser to open the diagram.
Click to select the node icon from the toolbar.
Click to place the node on the deployment
diagram.
While the node is still selected, enter its name
(Registration).
Add another node called Database to the
diagram.
Click to select the connection icon from the
toolbar.
Click on the node representing the Registration
computer and drag the connection to the node
representing the Database computer.
Rose may be used throughout the analysis and
design phases of development to visualize, analyze,
design, implement, and document a system under
development.
Download