This script will allow you to test drive Rational Rose 98 by building a model of a Course Registration
System for a University.
Requirements Rose 98 Setup Start Rational Rose !f you are using Rose "nterprise# do not use a $ramewor% &hit Cancel button on the $ramewor% 'i(ard). Turn off focus of control Tools*ptions menu command +iagram tab $ocus of Control chec%bo, +isplay all attributes and operations Tools*ptions menu command +iagram tab Show all -ttributes and Show all *perations chec%bo,es Set the default language to C.. Tools*ptions menu command /otation tab +efault language field &select the arrow to ma%e the drop down menu visible and select C..) Test +rive Rose C.. 0age 1 'e will start modeling the Course Registration 0roblem by creating a Use Case +iagram. This type of diagram consists of actors# use cases and the relationships between them. 2et3s open the 4ain Use Case +iagram. 1. Clic% the . ne,t to the Use Case 5iew pac%age in the 6rowser. 7. +ouble8clic% on the diagram called 4ain 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. $or our problem we have identified 9 actors : the Student# the 0rofessor# the Registrar and the 6illing System. 1. Clic% to select the actor icon from the tool bar &stic%man). 7. Clic% on the diagram to place the actor. ;. 'hile the actor is still selected# enter the name Student. 9. Repeat the above steps for the other three actors &Professor, Registrar and Billing System). Test +rive Rose C.. 0age 7 /e,t# we identify use cases for each of our actors. - use case is a piece of functionality that is provided by the system. <ou can identify uses cases by loo%ing at each actor and seeing how the actor interacts with the system. !n our model# the Student wants to Register for Courses. The 6illing System receives registration information. The 0rofessor wants to Request a Course Roster. $inally# the Registrar must 4anage the Curriculum. 1. Clic% to select the use case icon from the toolbar &oval). 7. Clic% on the diagram to place the use case. ;. 'hile the use case is still selected# enter the name Register for Courses. 9. Repeat the above steps for the other use cases. &Request Course Roster, Manage Curriculum). Relationships are drawn between the actors and the use cases. - uni8directional arrow is used to show the direction of the communication &who initiates the communication). !n the Course Registration system# the Student initiates the Register for Courses use case# which in turn communicates# with the 6illing System. The 0rofessor initiates the Request Course Roster use case. The Registrar initiates the 4anage Curriculum use case. 1. Clic% to select the uni8directional association icon from the toolbar &arrow). 7. Clic% on the Student actor and drag the line to the Register for Courses use case. ;. Clic% to select the uni8directional association icon from the toolbar. 9. Clic% on the Register for Courses use case and drag the association line to the 6illing System actor. =. Repeat the above steps for the other relationships &0rofessor actor to Request Course Roster use case and Registrar actor to 4anage Curriculum use case). /*T" !f you depress the Shift %ey prior to selecting the uni8directional arrow# you do not have to %eep re8 selecting it from the Toolbar. Test +rive Rose C.. 0age ; Use case functionality may be graphically shown in a Sequence +iagram. This diagram is one path through the flow of events for the use case : for e,ample# adding a student to a course. Sequence diagrams contain ob>ects and messages between the ob>ects that show how the behavior is reali(ed. 2et3s loo% at the ?-dd a Course@ sequence diagram for the ?Register for Courses@ use case. 1. Clic%8right on the Register for Courses use case in the 6rowser to ma%e the short cut menu visible. 7. Select the /ewSequence +iagram menu command. This will add a sequence diagram called New Diagram to the 6rowser. ;. 'hile the new diagram is still selected# enter the name Add a Course. 'e will then add the ob>ects and messages to the diagram to carry out the needed functionality. 'e open the diagram by double8clic%ing on the diagram in the 6rowser. 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. 'e3ll call our student ?Aoe@. 1. +ouble8clic% on the sequence diagram in the 6rowser to open the diagram. 7. Clic% to select the Student actor in the 6rowser and drag it onto the sequence diagram. ;. Clic% to select the actor on the sequence diagram and enter its name : Joe. Test +rive Rose C.. 0age 9 !n 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 ob>ect# which receives information from the student. 'e will create the form and add two messages# ?fill in info@ and ?submit@. 1. Clic% to select the ob>ect icon from the toolbar &rectangle). 7. Clic% on the sequence diagram to place the ob>ect. ;. 'hile the ob>ect is still selected enter the name registration form. 9. Clic% to select ob>ect message icon from the toolbar &arrow). =. Clic% on the dashed line for the Student actor and drag the arrow to the dashed line for the registration form ob>ect. B. 'hile the arrow is still selected# enter the message 88 fill in information. C. Repeat steps 9 through B to create the submit message. The form then sends a message to the manager. !t tells the manager that a student must be added to a course : Aoe wants to ta%e math 1D1. 1. Clic% to select the ob>ect icon from the toolbar &rectangle). 7. Clic% on the sequence diagram to place the ob>ect. ;. 'hile the ob>ect is still selected enter the name manager. 9. Clic% to select ob>ect message icon from the toolbar &arrow). =. Clic% on the dashed line for the registration form ob>ect and drag the arrow to the dashed line for the manager ob>ect. B. 'hile the arrow is still selected# enter the following message add Joe to Mat !"!# Test +rive Rose C.. 0age = The manager in turn tells 4ath 1D1 that Aoe would li%e to be added to the course. 1. Clic% to select the ob>ect icon from the toolbar &rectangle). 7. Clic% on the sequence diagram to place the ob>ect. ;. 'hile the ob>ect is still selected enter the name mat !"!. 9. Clic% to select ob>ect message icon from the toolbar &arrow). =. Clic% on the dashed line for the manager ob>ect and drag the arrow to the dashed line for the math 1D1 ob>ect. B. 'hile the arrow is still selected# enter the following message add Joe# The course in turn# as%s the course offering if it is open &in this scenario# the answer is yes) so it tells the offering to add >oe. 1. Clic% to select the ob>ect icon from the toolbar &rectangle). 7. Clic% on the sequence diagram to place the ob>ect. ;. 'hile the ob>ect is still selected enter the name 88 section !. 9. Clic% to select ob>ect message icon from the toolbar &arrow). =. Clic% on the dashed line for the math 1D1 ob>ect and drag the arrow to the dashed line for the section 1 ob>ect. B. 'hile the arrow is still selected# enter the following message acce$ting students% C. Repeat steps 9 through B to create the message add Joe## Test +rive Rose C.. 0age B $inally# the billing system is notified that Aoe is ta%ing math 1D1. 1. Clic% to select the ob>ect icon from the toolbar &rectangle). 7. Clic% on the sequence diagram to place the ob>ect. ;. 'hile the ob>ect is still selected enter the name bill. 9. Clic% to select ob>ect message icon from the toolbar &arrow). =. Clic% on the dashed line for the manager ob>ect and drag the arrow to the dashed line for the bill ob>ect. B. 'hile the arrow is still selected# enter the following message Send bill for Mat !"! to Joe# The ob>ects in the sequence diagrams are grouped into classes. - class is a template for creating ob>ects >ust li%e a coo%ie cutter is used to create coo%ies. 6ased on our sequence diagram we can identify the following ob>ects and classes registration form is an ob>ect in the Reg$orm class manager is an ob>ect in the 4anager class math 1D1 is an ob>ect in the Course class section 1 is an ob>ect in the Course*ffering class bill is the interface to the e,ternal billing system# so we will use 6illingSystem as the name of its class. Classes are created in the 2ogical 5iew of the tool. 1. Clic%8right on the 2ogical 5iew pac%age in the 6rowser to ma%e the shortcut menu visible. 7. Select the /ewClass menu command. This will add a class called /ewClass to the 6rowser. ;. 'hile the class is still selected# enter the name Reg&orm# 9. Repeat the above steps for the additional classes Manager, Course, Course'ffering and BillingSystem -s classes are created# they should be documented. +ocumentation is added via the +ocumentation 'indow. Test +rive Rose C.. 0age C 1. Clic% to select the Course*ffering class in the 6rowser. 7. "nter its documentation in the +ocumentation 'indow. 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. - 6rowser view of the classes is good but a picture is also needed. That is where class diagrams come into play. 2et3s open the 4ain class diagram and add our classes to it. 1. +ouble8clic% on the diagram called 4ain in the 6rowser to open the diagram. 7. Select the Euery-dd Classes menu command. ;. Select the -llFF button to add all the classes. 9. Clic% the *G button to close the window and add the classes to the diagram. =. Re8arrange the classes on the diagram as needed by selecting the class and dragging it to its new location. /*T" Classes can also be added to the diagram by dragging them from the 6rowser onto the diagram. This can only be done for one class at a time. Test +rive Rose C.. 0age 8 The U42 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. 'e will use the pre8defined stereotype of !nterface for the 6illingSystem class since this is the class that is the interface to the e,ternal billing system 1. +ouble8clic% on the 6illingSystem class on the 4ain class diagram to ma%e the Specification visible. 1. Clic% the arrow in the Stereotype field to ma%e the drop down menu visible. 7. Select the !nterface stereotype. ;. Clic% the *G button to close the Specification. Relationships between classes are added to facilitate ob>ect communication. Sequence diagrams are e,amined to see what ob>ects must tal% to one another. !f ob>ects must tal% then there must be a pathway for communication between their classes. Two common types of relationships are associations and aggregations. -n association is a bi8directional connection between classes. 6y e,amining the ?-dd a Course@ sequence diagram we can determine that the following associations e,ist Reg$orm to 4anager# 4anager to Course and 4anager to 6illingSystem. 1. Clic% to select the association icon from the toolbar &line). 7. Clic% on the Reg&orm class and drag the association line to the Manager class. ;. Repeat the above steps for the following relationships Manager and Course Manager and BillingSystem. Test +rive Rose C.. 0age 9 -n aggregation is a stronger form of association. !t shows the relationship between a whole and its parts. 'e will create an aggregation relationship between the Course and the Course*ffering classes &a Course is comprised of Course*fferings). 1. Clic% to select the aggregation icon from the toolbar &line with a diamond). 7. Clic% to select the class representing the part : Course*ffering. ;. +rag the aggregation line to the class representing the whole : Course. 4ultiplicity indicators are added to the relationships in the model to show ?how many@ ob>ects participate in the relationship. 1. Clic%8right on the aggregation line near the Course*ffering class. 7. Select the 4ultiplicity*ne or 4ore menu command. ;. Clic%8right on the aggregation line near the Course class. 9. Select the 4ultipliciy1 menu command. Test +rive Rose C.. 0age 1D The structure of a class is represented by its set of attributes. Structure is found by e,amining the problem requirements and through conversions with domain e,perts and customers. !n our model# each Course*ffering is held at a specific location : this is an attribute. 1. Clic%8right on the Course*ffering class on the class diagram. 7. Select the /ew-ttribute menu command. This will add an attribute called HHFFname typeIinitval to the class. ;. 'hile the new attribute is still selected# enter its name : numberStudents. The behavior of a class is represented by its set of operations. *perations are initially discovered by mapping the messages in sequence diagrams to operations. The first step is to assign the ob>ects in the sequence diagram to classes. 1. *pen the -dd a Course sequence diagram by double clic%ing on the diagram in the 6rowser. 7. Clic% to select the Course*ffering class in the 6rowser. ;. +rag the Course*ffering class onto the section 1 ob>ect. Test +rive Rose C.. 0age 11 *nce an ob>ect is assigned to a class# you can map the messages it receives to new operations or to operations that have already been defined for the class. 1. Clic%8right on the ?accepting students J@ message to ma%e the shortcut menu visible. 7. Select the Hnew operationF menu command to ma%e the *peration Specification visible. ;. "nter the name of the new operation : offering*pen. 9. Clic% the *G button to close the *peration specification. *nce a new operation has been created# messages may be mapped to the operation. 1. Clic%8right on the ?accepting studentsJ@ message to ma%e the shortcut menu visible. 7. Select the offering*pen&) operation. *perations created are automatically added to the Class in the 2ogical 5iew of the model. -s you progress along the analysis and design timeline# design decisions are added to the model. /avigation shows what ob>ects can send messages. 6y default# associations and aggregations are navigable in both directions. +uring design# navigation may be set to only one direction &arrow added to show the navigation direction). Scenario diagrams are used to help you ma%e navigation decisions. !n Test +rive Rose C.. 0age 17 our model# the Course sends messages to the Course*ffering but the Course*ffering does not send messages to the Course. This means that you cannot navigate from the Course*ffering to the Course. 1. *pen the 4ain class diagram by double clic%ing on it in the browser. 7. Clic%8right on the aggregation line near the Course class. ;. Select the /avigable menu command &this will toggle navigation in that direction). *nce the language has been chose# attributes are given data types and operation signatures are finali(ed. Kere# we are using the C.. language. 1. +ouble8clic% on the Course*ffering class in either the 6rowser or on a class diagram to ma%e the Specification visible. 7. Select the -ttributes tab. ;. Clic% in the Type field to ma%e the drop down menu visible. 9. Select the desired data type &select long). =. Clic% the *G button to close the Specification. /*T" attribute data types may also be set using the -ttribute specification or by typing in place if the attribute is displayed on a class diagram &format is attribute(data ty$e). Test +rive Rose C.. 0age 1; 1. +ouble8clic% on the Course*ffering class in either the 6rowser or on a class diagram to ma%e the Specification visible. 7. Select the *perations tab. ;. Clic% in the Return type field to ma%e the drop down menu visible. 9. Select the desired return type &select long). =. Clic% the *G button to close the Specification. /*T" *peration arguments are set using the *peration Specification. *peration arguments and return type my also be set by typing in place if the operation is displayed on a class diagram &format is o$eration)argument name(data ty$e*(return ty$e). "ventually# you reach a point where it is time to generate code for the classes in the model. Kere# we use the Component 5iew of the tool to specify the source code components in our system. Rose automatically creates one component diagram called 4ain. 1. Clic% the . ne,t to the Component 5iew pac%age in the 6rowser to e,pand the pac%age. 7. +ouble8clic% on the diagram called 4ain to open the main component diagram. Test +rive Rose C.. 0age 19 !n our model# we will have one component to represent the header file for the Course*ffering class and one component to represent the .cpp file for the Course*ffering class. Stereotypes are used to differentiate the .h and .cpp files. .h files have a stereotype of 0ac%age Specification and .cpp files have a stereotype of 0ac%age 6ody. 1. Clic% to select the component icon from the toolbar. 7. Clic% on the diagram to place the component. ;. 'hile the new component is still selected# enter its name 88 Course'ffering. 9. +ouble8clic% on the Course*ffering component to ma%e the Component Specification visible. =. Clic% the arrow in the Stereotype field to ma%e the drop down menu visible. B. Select 0ac%age Specification. C. Clic% the *G button to close the specification. 8. Repeat the above steps using the 0ac%age 6ody stereotype. 9. Clic% to select the dependency relationship icon from the toolbar. 1D. Clic% on the component representing the .cpp file &pac%age body stereotype) and drag the arrow to the component representing the .h file &pac%age specification stereotype). "ach component is assigned a language. This implies that all classes assigned to the component will be implemented in the assigned language. 'e will assign the components to the C.. language. 1. +ouble8clic% on the Course*ffering component representing the .h file &pac%age specification stereotype) on the component diagram or in the 6rowser to ma%e the Component Specification visible. 7. Clic% the arrow in the 2anguage field to ma%e the drop down menu visible. ;. Select the desired language : C... 9. Clic% the *G button to close the Specification.. =. Repeat the above steps for the Course*ffering component representing the .cpp file &pac%age body stereotype). *nce components are created# classes in the model must be assigned to the component. Test +rive Rose C.. 0age 1= 1. +ouble8clic% on the Course*ffering component representing the .h file &pac%age specification stereotype) on the diagram or in the 6rowser to ma%e the Specification visible. 7. Select the Reali(es tab. ;. Clic%8right on the Course*ffering class to ma%e the shortcut menu visible. 9. Select the -ssign menu command. =. Clic% the *G button to close the Specification. The Tools menu contains the command to generate C.. code. 1. Clic% to select the Course*ffering components &both components) on the component diagram. 7. Select the ToolsC.. Code Leneration menu command. Test +rive Rose C.. 0age 1B Code generation status is shown in the Code Leneration Status window. -ll errors are written to the log. 1. Clic% the Close button to complete the code generation process. 2et3s loo% at the code generated by Rose. 1. Clic% to select the component representing the .h file for the Course*ffering class on the component diagram. 7. Select the ToolsC.. 6rowse Keader menu command. Test +rive Rose C.. 0age 1C <ou will notice that the documentation that was added to the model is also added to the code. -s you loo% at the code# you will notice that there are methods generated that were not specified in the model : for e,ample a constructor# a destructor# and getMset methods. This is due to the fact that Rose has a very robust set of code generation properties that may be used to tailor the generated code. $or more information on code generation properties# see the Rose help. /ow comes the 1DDD8dollar question. <ou have done your analysis and design# generated the code and are implementing the methods when you discover that you need another operation. Kow many fol%s will go Test +rive Rose C.. 0age 18 bac% to the model# add the operation and re8generate the code J 0robably no one : you will update the codeN 1. "nter the name of the new method : incrementCount &ma%e the return type long) to the Course*ffering.h file. 7. Save the .h file. 'e now have a problem# our code says one thing and our model says another thing. This is where reverse engineering comes into play. 1. To start the C.. -naly(er# select the ToolsC..Reverse "ngineering menu command. 1. To create a new analy(er pro>ect# select the $ile/ew menu command. Test +rive Rose C.. 0age 19 The ne,t step is to tell the analy(er what directories include the files you want to analy(e. 1. Clic% the +irectories button to ma%e the 0ro>ect +irectory 2ist window visible. 7. /avigate through the directories shown in the +irectory Structure field to find the directory containing the files to reverse engineered. ;. Clic% the -dd Current button to add the directory. 9. Clic% the *G button to close the 0ro>ect +irectory 2ist window. 'e now need to add the files to our analy(er pro>ect. Test +rive Rose C.. 0age 7D 1. Clic% the $iles button to ma%e the 0ro>ect $iles window visible. 7. Select the desired files from the $iles /ot !n 2ist field. ;. Clic% the -dd Selected button. 9. Clic% the *G button to close the 0ro>ect $iles window. /ow that our pro>ect is set up# it is time to reverse engineer the files. 1. Clic% to select the files to be reverse engineered. 7. Select the -ctionCode Cycle menu command. <ou will be as%ed if it is o% for Rose to update the files being analy(ed &Rose will add code mar%ers if necessary to facilitate forward engineering). 1. Clic% the <es button to continue the reverse engineering process. Test +rive Rose C.. 0age 71 /*T" Rose will update the status for each file being analy(ed. Code cycled means success. -fter the file&s) are reverse engineered# they must be e,ported to Rose. 1. Select the -ction",port to Rose menu command to ma%e the ",port to Rose window visible. 7. Clic% the arrow in the *ption Set field to ma%e the drop down menu visible. ;. Select the Round Trip option. 9. Clic% the *G button to close the window. /ow the Rose model must be updated with the information obtained from the reverse engineering process. 1. Select the $ileUpdate menu command to ma%e the Update 4odel $rom window visible. Test +rive Rose C.. 0age 77 1. Use the arrow in the 2oo% !n field to go to the directory containing the .red file &file created by the C. . analy(er). 7. Clic% to select the desired .red file. ;. Clic% the *pen button to update the Rose model. Update status is displayed in the 4erge Status window. 1. Clic% the Close button to close the 4erge Status window. Test +rive Rose C.. 0age 7; <ou will notice that the operation that we added in the code &incrementCount) is now present in the Rose model. !n this short demo# you have seen how Rational Rose may be used throughout the analysis and design phases of development to visuali(e# analy(e# design# implement# and document a system under development. Test +rive Rose C.. 0age 79