![](/user_photo/1334_ivfwg.png)
- •Table of Contents
- •Mastering UML with Rational Rose 2002
- •Chapter 1: Introduction to UML
- •Encapsulation
- •Inheritance
- •Polymorphism
- •What Is Visual Modeling?
- •Systems of Graphical Notation
- •Booch Notation
- •Object Management Technology (OMT)
- •Unified Modeling Language (UML)
- •Understanding UML Diagrams
- •Business Use Case Diagrams
- •Use Case Diagrams
- •Activity Diagrams
- •Sequence Diagrams
- •Collaboration Diagrams
- •Class Diagrams
- •Statechart Diagrams
- •Component Diagrams
- •Deployment Diagrams
- •Visual Modeling and the Software Development Process
- •Inception
- •Elaboration
- •Construction
- •Transition
- •Summary
- •Chapter 2: A Tour of Rose
- •What Is Rose?
- •Getting Around in Rose
- •Parts of the Screen
- •Exploring Four Views in a Rose Model
- •Use Case View
- •Logical View
- •Component View
- •Deployment View
- •Working with Rose
- •Creating Models
- •Saving Models
- •Exporting and Importing Models
- •Publishing Models to the Web
- •Working with Controlled Units
- •Using the Model Integrator
- •Working with Notes
- •Working with Packages
- •Adding Files and URLs to Rose Model Elements
- •Adding and Deleting Diagrams
- •Setting Global Options
- •Working with Fonts
- •Working with Colors
- •Summary
- •Chapter 3: Business Modeling
- •Introduction to Business Modeling
- •Why Model the Business?
- •Do I Need to Do Business Modeling?
- •Business Modeling in an Iterative Process
- •Business Actors
- •Business Workers
- •Business Use Cases
- •Business Use Case Diagrams
- •Activity Diagrams
- •Business Entities
- •Organization Unit
- •Where Do I Start?
- •Identifying the Business Actors
- •Identifying the Business Workers
- •Identifying the Business Use Cases
- •Showing the Interactions
- •Documenting the Details
- •Creating Business Use Case Diagrams
- •Deleting Business Use Case Diagrams
- •The Use Case Diagram Toolbar
- •Adding Business Use Cases
- •Business Use Case Specifications
- •Assigning a Priority to a Business Use Case
- •Viewing Diagrams for a Business Use Case
- •Viewing Relationships for a Business Use Case
- •Working with Business Actors
- •Adding Business Actors
- •Adding Actor Specifications
- •Assigning an Actor Stereotype
- •Setting Business Actor Multiplicity
- •Viewing Relationships for a Business Actor
- •Working with Relationships
- •Association Relationship
- •Generalization Relationship
- •Working with Organization Units
- •Adding Organization Units
- •Deleting Organization Units
- •Activity Diagrams
- •Adding an Activity Diagram
- •Adding Details to an Activity Diagram
- •Summary
- •Chapter 4: Use Cases and Actors
- •Use Case Modeling Concepts
- •Actors
- •Use Cases
- •Traceability
- •Flow of Events
- •Relationships
- •Use Case Diagrams
- •Activity Diagrams
- •Activity
- •Start and End States
- •Objects and Object Flows
- •Transitions
- •Synchronization
- •Working with Use Cases in Rational Rose
- •The Use Case Diagram Toolbar
- •Creating Use Case Diagrams
- •Deleting Use Case Diagrams
- •Adding Use Cases
- •Deleting Use Cases
- •Use Case Specifications
- •Naming a Use Case
- •Viewing Participants of a Use Case
- •Assigning a Use Case Stereotype
- •Assigning a Priority to a Use Case
- •Creating an Abstract Use Case
- •Viewing Diagrams for a Use Case
- •Viewing Relationships for a Use Case
- •Working with Actors
- •Adding Actors
- •Deleting Actors
- •Actor Specifications
- •Naming Actors
- •Assigning an Actor Stereotype
- •Setting Actor Multiplicity
- •Creating an Abstract Actor
- •Viewing Relationships for an Actor
- •Viewing an Actor's Instances
- •Working with Relationships
- •Association Relationship
- •Includes Relationship
- •Extends Relationship
- •Generalization Relationship
- •Working with Activity Diagrams
- •The Activity Diagram Toolbar
- •Creating Activity Diagrams
- •Deleting Activity Diagrams
- •Exercise
- •Problem Statement
- •Create a Use Case Diagram
- •Summary
- •Chapter 5: Object Interaction
- •Interaction Diagrams
- •What Is an Object?
- •What Is a Class?
- •Where Do I Start?
- •Finding Objects
- •Finding the Actor
- •Using Interaction Diagrams
- •Sequence Diagrams
- •The Sequence Diagram Toolbar
- •Collaboration Diagrams
- •The Collaboration Diagram Toolbar
- •Working with Actors on an Interaction Diagram
- •Working with Objects
- •Adding Objects to an Interaction Diagram
- •Deleting Objects from an Interaction Diagram
- •Setting Object Specifications
- •Naming an Object
- •Mapping an Object to a Class
- •Setting Object Persistence
- •Using Multiple Instances of an Object
- •Working with Messages
- •Adding Messages to an Interaction Diagram
- •Adding Messages to a Sequence Diagram
- •Deleting Messages from a Sequence Diagram
- •Reordering Messages in a Sequence Diagram
- •Message Numbering in a Sequence Diagram
- •Viewing the Focus of Control in a Sequence Diagram
- •Adding Messages to a Collaboration Diagram
- •Deleting Messages from a Collaboration Diagram
- •Message Numbering in a Collaboration Diagram
- •Adding Data Flows to a Collaboration Diagram
- •Setting Message Specifications
- •Naming a Message
- •Mapping a Message to an Operation
- •Setting Message Synchronization Options
- •Setting Message Frequency
- •End of a Lifeline
- •Working with Scripts
- •Switching Between Sequence and Collaboration Diagrams
- •Exercise
- •Problem Statement
- •Create Interaction Diagrams
- •Summary
- •Chapter 6: Classes and Packages
- •Logical View of a Rose Model
- •Class Diagrams
- •What Is a Class?
- •Finding Classes
- •Creating Class Diagrams
- •Deleting Class Diagrams
- •Organizing Items on a Class Diagram
- •Using the Class Diagram Toolbar
- •Working with Classes
- •Adding Classes
- •Class Stereotypes
- •Analysis Stereotypes
- •Class Types
- •Interfaces
- •Web Modeling Stereotypes
- •Other Language Stereotypes
- •Class Specifications
- •Naming a Class
- •Setting Class Visibility
- •Setting Class Multiplicity
- •Setting Storage Requirements for a Class
- •Setting Class Persistence
- •Setting Class Concurrency
- •Creating an Abstract Class
- •Viewing Class Attributes
- •Viewing Class Operations
- •Viewing Class Relationships
- •Using Nested Classes
- •Viewing the Interaction Diagrams That Contain a Class
- •Setting Java Class Specifications
- •Setting CORBA Class Specifications
- •Working with Packages
- •Adding Packages
- •Deleting Packages
- •Exercise
- •Problem Statement
- •Creating a Class Diagram
- •Summary
- •Chapter 7: Attributes and Operations
- •Working with Attributes
- •Finding Attributes
- •Adding Attributes
- •Deleting Attributes
- •Setting Attribute Specifications
- •Setting the Attribute Containment
- •Making an Attribute Static
- •Specifying a Derived Attribute
- •Working with Operations
- •Finding Operations
- •Adding Operations
- •Deleting Operations
- •Setting Operation Specifications
- •Adding Arguments to an Operation
- •Specifying the Operation Protocol
- •Specifying the Operation Qualifications
- •Specifying the Operation Exceptions
- •Specifying the Operation Size
- •Specifying the Operation Time
- •Specifying the Operation Concurrency
- •Specifying the Operation Preconditions
- •Specifying the Operation Postconditions
- •Specifying the Operation Semantics
- •Displaying Attributes and Operations on Class Diagrams
- •Showing Attributes
- •Showing Operations
- •Showing Visibility
- •Showing Stereotypes
- •Mapping Operations to Messages
- •Mapping an Operation to a Message on an Interaction Diagram
- •Exercise
- •Problem Statement
- •Add Attributes and Operations
- •Summary
- •Chapter 8: Relationships
- •Relationships
- •Types of Relationships
- •Finding Relationships
- •Associations
- •Using Web Association Stereotypes
- •Creating Associations
- •Deleting Associations
- •Dependencies
- •Creating Dependencies
- •Deleting Dependencies
- •Package Dependencies
- •Creating Package Dependencies
- •Deleting Package Dependencies
- •Aggregations
- •Creating Aggregations
- •Deleting Aggregations
- •Generalizations
- •Creating Generalizations
- •Deleting Generalizations
- •Working with Relationships
- •Setting Multiplicity
- •Using Relationship Names
- •Using Stereotypes
- •Using Roles
- •Setting Export Control
- •Using Static Relationships
- •Using Friend Relationships
- •Setting Containment
- •Using Qualifiers
- •Using Link Elements
- •Using Constraints
- •Exercise
- •Problem Statement
- •Adding Relationships
- •Summary
- •Chapter 9: Object Behavior
- •Statechart Diagrams
- •Creating a Statechart Diagram
- •Adding States
- •Adding State Details
- •Adding Transitions
- •Adding Transition Details
- •Adding Special States
- •Using Nested States and State History
- •Exercise
- •Problem Statement
- •Create a Statechart Diagram
- •Summary
- •Chapter 10: Component View
- •What Is a Component?
- •Types of Components
- •Component Diagrams
- •Creating Component Diagrams
- •Adding Components
- •Adding Component Details
- •Adding Component Dependencies
- •Exercise
- •Problem Statement
- •Summary
- •Chapter 11: Deployment View
- •Deployment Diagrams
- •Opening the Deployment Diagram
- •Adding Processors
- •Adding Processor Details
- •Adding Devices
- •Adding Device Details
- •Adding Connections
- •Adding Connection Details
- •Adding Processes
- •Exercise
- •Problem Statement
- •Create Deployment Diagram
- •Summary
- •Chapter 12: Introduction to Code Generation and Reverse Engineering Using Rational Rose
- •Preparing for Code Generation
- •Step One: Check the Model
- •Step Two: Create Components
- •Step Three: Map Classes to Components
- •Step Five: Select a Class, Component, or Package
- •Step Six: Generate Code
- •What Gets Generated?
- •Introduction to Reverse Engineering Using Rational Rose
- •Model Elements Created During Reverse Engineering
- •Summary
- •Chapter 13: ANSI C++ and Visual C++ Code Generation and Reverse Engineering
- •Generating Code in ANSI C++ and Visual C++
- •Converting a C++ Model to an ANSI C++ Model
- •Class Properties
- •Attribute Properties
- •Operation Properties
- •Package (Class Category) Properties
- •Component (Module Specification) Properties
- •Role Properties
- •Generalization Properties
- •Class Model Assistant
- •Component Properties
- •Project Properties
- •Visual C++ and ATL Objects
- •Generated Code
- •Code Generated for Classes
- •Code Generated for Attributes
- •Code Generated for Operations
- •Visual C++ Code Generation
- •Reverse Engineering ANSI C++
- •Reverse Engineering Visual C++
- •Summary
- •Overview
- •Introduction to Rose J
- •Beginning a Java Project
- •Selecting a Java Framework
- •Linking to IBM VisualAge for Java
- •Linking to Microsoft Visual J++
- •Project Properties
- •Class Properties
- •Attribute Properties
- •Operation Properties
- •Module Properties
- •Role Properties
- •Generating Code
- •Generated Code
- •Classes
- •Attributes
- •Operations
- •Bidirectional Associations
- •Unidirectional Associations
- •Associations with a Multiplicity of One to Many
- •Associations with a Multiplicity of Many to Many
- •Reflexive Associations
- •Aggregations
- •Dependency Relationships
- •Generalization Relationships
- •Interfaces
- •Java Beans
- •Support for J2EE
- •EJBs
- •Servlets
- •JAR and WAR Files
- •Automated J2EE Deployment
- •Reverse Engineering
- •Summary
- •Starting a Visual Basic Project
- •Class Properties
- •Attribute Properties
- •Operation Properties
- •Module Specification Properties
- •Role Properties
- •Generalization Properties
- •Generated Code
- •Classes
- •Attributes
- •Operations
- •Bidirectional Associations
- •Unidirectional Associations
- •Associations with a Multiplicity of One to Many
- •Associations with a Multiplicity of Many to Many
- •Reflexive Associations
- •Aggregations
- •Dependency Relationships
- •Generalization Relationships
- •Reverse Engineering
- •Summary
- •Overview
- •Introduction to XML DTD
- •Elements
- •Attributes
- •Entities and Notations
- •Project Properties
- •Class Properties
- •Attribute Properties
- •Role Properties
- •Component Properties
- •Generating Code
- •Generated Code
- •Classes
- •Attributes
- •Reverse Engineering DTD
- •Summary
- •Project Properties
- •Class Properties
- •Attribute Properties
- •Operation Properties
- •Module Properties
- •Association (Role) Properties
- •Dependency Properties
- •Generated Code
- •Classes
- •Attributes
- •Operations
- •Bidirectional Associations
- •Unidirectional Associations
- •Associations with a Multiplicity of One to Many
- •Associations with a Multiplicity of Many to Many
- •Associations with Bounded Multiplicity
- •Reflexive Associations
- •Aggregations
- •Dependency Relationships
- •Generalization Relationships
- •Reverse Engineering CORBA Source Code
- •Summary
- •Chapter 18: Rose Data Modeler
- •Object Models and Data Models
- •Creating a Data Model
- •Logic in a Data Model
- •Adding a Database
- •Adding Tablespaces
- •Adding a Schema
- •Creating a Data Model Diagram
- •Creating Domain Packages and Domains
- •Adding Tables
- •Adding Columns
- •Setting a Primary Key
- •Adding Constraints
- •Adding Triggers
- •Adding Indexes
- •Adding Stored Procedures
- •Adding Relationships
- •Adding Referential Integrity Rules
- •Working with Views
- •Generating an Object Model from a Data Model
- •Generating a Data Model from an Object Model
- •Generating a Database from a Data Model
- •Updating an Existing Database
- •Reverse Engineering a Database
- •Summary
- •Chapter 19: Web Modeling
- •Modeling a Web Application
- •Web Class Stereotypes
- •Relationships
- •Reverse Engineering a Web Application
- •Generating Code for a Web Application
- •Summary
- •Appendix: Getting Started with UML
- •Building a Business Use Case Diagram
- •Building a Workflow (Activity) Diagram
- •Building a Use Case Diagram
- •Building an Interaction Diagram
- •Building a Class Diagram
- •Web Modeling
- •Adding Class Relationships
- •Building a Statechart Diagram
- •Building a Component Diagram
- •Building a Deployment Diagram
![](/html/1334/288/html_hMM93oGmoc.litP/htmlconvd-5UmcB1514x1.jpg)
Chapter 15: Visual Basic Code Generation and Reverse Engineering
Whether an indefinite number of parameters may be passed for the operation (ParamArray field)
Each of these settings will affect the generated code.
Module Specification Properties
The module specification properties are related to the project files you will generate from Rose. There are three places to set these properties. To set them for all components, select Tools → Options, then click the Visual Basic tab and select Module Specification from the drop−down list box. To set them for only one component, select the Visual Basic tab on the component specification window and edit the properties there, or use the Visual Basic Component Properties window.
Table 15.4 lists the code−generation properties for components, their purposes, and their default values.
Table 15.4: Module Specification Code−Generation Properties
Property |
Purpose |
Default |
ProjectFile |
Sets the name of the project file |
<Set using the Code |
|
|
Generation Wizard> |
UpdateCode |
Specifies if code can be generated for this component |
True |
UpdateModel |
Specifies if the model can be updated for this |
True |
|
component |
|
ImportReferences |
Specifies whether to import ActiveX components |
True |
QuickImport |
Specifies whether to import only ActiveX interface |
True |
|
classes or all classes including methods and |
|
|
operations |
|
ImportBinary |
Determines whether Rose should import the type |
False |
|
library for the component on the next reverse engineer |
|
502
![](/html/1334/288/html_hMM93oGmoc.litP/htmlconvd-5UmcB1515x1.jpg)
Chapter 15: Visual Basic Code Generation and Reverse Engineering
To open the Visual Basic Component Properties window, as shown in Figure 15.6, right−click the component and select Properties.
Figure 15.6: VB Component Properties Window
The Should Be Generated and Should Be Updated from Code fields correspond to the UpdateCode and UpdateModel properties, respectively. The Project File field corresponds to the ProjectFile property. Using the References tab, you can set the QuickImport, ImportBinary, and ImportReferences properties.
Role Properties
Role properties are the Visual Basic code−generation properties that affect the code generated for relationships. The role properties let you set the name of the attribute that is created; control the generation of Get, Set, and Let operations; and change other specific pieces of the generated code.
503
![](/html/1334/288/html_hMM93oGmoc.litP/htmlconvd-5UmcB1516x1.jpg)
Chapter 15: Visual Basic Code Generation and Reverse Engineering
There are two places to set these properties. To set them for all associations, select Tools → Options, then click the Visual Basic tab and select Role from the drop−down list box. To set them for only one operation, select the Visual Basic tab on the association specification window and edit the properties there. Table 15.5 lists the code−generation property for roles.
Table 15.5: Role Code−Generation Properties
Property |
Purpose |
Default |
UpdateCode |
Specifies if code can be generated for this role |
True |
New |
Controls if the association is generated with a new |
False |
|
modifier |
|
WithEvents |
Controls if the association is generated with the With |
False |
|
Events modifier |
|
Fullname |
Specifies whether to use the full name of the |
False |
|
referenced class in the property declaration |
|
PropertyName |
The name of the property to which the attribute |
<blank> |
|
created to support the relationship belongs |
|
Subscript |
Specifies the array subscript for an attribute |
<blank> |
ProcedureID |
Sets the Visual Basic procedure ID |
<blank> |
Generalization Properties
Generalization properties are the Visual Basic code−generation properties that affect the code generated for generalization relationships. As Visual Basic does not support inheritance, there are only two properties for generalization relationships. The ImplementsDelegation property controls whether the generalization is realized by an implements delegation. The FullName property controls whether the full name of the class, including the component name, should be used in the implements statement.
504
![](/html/1334/288/html_hMM93oGmoc.litP/htmlconvd-5UmcB1517x1.jpg)
Chapter 15: Visual Basic Code Generation and Reverse Engineering
There are two places to set these properties. To set them for all generalizations, select Tools → Options, then click the Visual Basic tab and select Generalize from the drop−down list box. To set them for only one generalization, select the Visual Basic tab on the generalization specification window and edit the properties there.
Using the Code−Generation Wizard
After you create classes and associations in the Rose model, you can use a Code−Generation Wizard to generate the Visual Basic code. To begin this process, select the objects to generate, then select Tools → Visual Basic → Update Code from the menu. You will see the screen shown in Figure 15.7.
Figure 15.7: Code−Generation Wizard
505
![](/html/1334/288/html_hMM93oGmoc.litP/htmlconvd-5UmcB1518x1.jpg)
Chapter 15: Visual Basic Code Generation and Reverse Engineering
If you have not yet assigned the objects to components, you will see a window like the one in Figure 15.8. You have the option of assigning the classes to an existing component (in this example, there is a single component called Airline Reservation with a stereotype of Standard EXE). Alternatively, you can create a new component and assign classes to it.
Figure 15.8: Assigning components and classes
To assign classes to an existing component, right−click the component in the Code−Generation Wizard shown in Figure 15.8 and select Assign Classes. You will see a list of unassigned classes:
Drag and drop each class from the right side of the screen to the appropriate component on the left side. Once all classes are assigned, click OK.
To create a new component, select the Create a Visual Basic Component and Assign Classes to It option, as shown in Figure 15.8, or press Ctrl+R. You will be asked what type of component to create:
506
![](/html/1334/288/html_hMM93oGmoc.litP/htmlconvd-5UmcB1519x1.jpg)
Chapter 15: Visual Basic Code Generation and Reverse Engineering
Select the appropriate type (in this example, we use a Standard EXE) and press OK. The component will be added, and all unassigned classes will be assigned to it:
Check the box next to the components or classes you wish to update. Notice that if you click on a class, you can preview the code that will be generated for the attributes and operations of that class:
Right−click and select Open to view the properties for an object in the treeview. Rose will display the appropriate Model Assistant screen, and allow you to modify any code−generation properties before the final code is generated. For example, right−clicking the Flight class will display the screen shown in Figure 15.9.
507
![](/html/1334/288/html_hMM93oGmoc.litP/htmlconvd-5UmcB1520x1.jpg)
Chapter 15: Visual Basic Code Generation and Reverse Engineering
Figure 15.9: Setting code−generation properties for the Flight class
Once all classes have been assigned and all code−generation properties are set, click Next to complete the process. You will see a summary screen, as shown in Figure 15.10. Press Finish to generate the code. If Visual Basic is not already running, Rose will launch it and create the appropriate project, classes, and other elements.
Figure 15.10: Code−generation summary screen
An example of the code generated for the Flight class follows below. In the remainder of this chapter, we will discuss the mapping between a Rose model and Visual Basic code.
Option Explicit
'##ModelId=3A818E9F01D0 Private DepartureCity As String
'##ModelId=3A818EAC02C9 Private DepartureDate As String
'##ModelId=3A818EB300CA
Private DestinationCity As String
'##ModelId=3A818EB70134 Private FlightNumber As String
'##ModelId=3A818ECE01A6
508