![](/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-5UmcB1316x1.jpg)
Chapter 8: Relationships
different types of employees, hourly and salaried. This may indicate that you should have an HourlyEmp class and a SalariedEmp class, each of which inherit from an Employee class. Attributes, operations, and relationships that are common to all employees are placed in the Employee class. Attributes, operations, or relationships that are unique to hourly or salaried employees are placed in the HourlyEmp or SalariedEmp classes.
4.
Examine your classes to look for additional generalization relationships. Try to find classes that have a great deal in common. For example, you may have two classes called CheckingAccount and SavingsAccount. Both have similar information and behavior. You can create a third class, called Account, to hold the information and behavior common to a checking and a savings account.
Be cautious of classes with too many relationships. One goal of a well−designed application is to reduce unnecessary relationships in the system. A class with many relationships may need to know about a great many other classes. It can therefore be harder to reuse, and your maintenance effort may also be greater. If any of the other classes change, the original class may be affected.
Associations
An association is a semantic connection between classes. An association allows one class to know about the public attributes and operations of another class. For example, in Figure 8.6, we have a bidirectional association between Flight and Customer.
Figure 8.6: Association relationship between the Flight class and the Customer class
The Flight class knows about the public attributes and operations of Customer, and the Customer class knows about the public attributes and operations of Flight. On a Sequence diagram, therefore, Flight can send messages to Customer, and Customer can send messages to Flight.
304
![](/html/1334/288/html_hMM93oGmoc.litP/htmlconvd-5UmcB1317x1.jpg)
Chapter 8: Relationships
In the example above, the relationship is bidirectional. However, you will want to refine most of your associations to be unidirectional. Unidirectional relationships are easier to build and to maintain, and can help you find classes that can be reused. Let's look at the above example again, but this time the association is unidirectional. Figure 8.7 shows the unidirectional relationship.
Figure 8.7: Unidirectional association relationship
In this case, the Flight class knows about the public attributes and operations of Customer, but Customer does not know about the public attributes and operations of Flight. Messages on a Sequence or Collaboration diagram can be sent by Flight and received by Customer, but cannot be sent by Customer.
You can determine the direction of an association by looking at the Sequence and Collaboration diagrams. If every message on the Interaction diagrams is sent by Flight and received by Customer, there is a unidirectional relationship from Flight to Customer. If there is even one message from Customer to Flight, you will need a bidirectional relationship.
Unidirectional relationships can help you identify classes that are good candidates for reuse. If the association between Flight and Customer is bidirectional, each class needs to know about the other; neither class can, therefore, be reused without the other. But assume instead that there is a unidirectional relationship from Flight to Customer. Flight needs to know about Customer, so it can't be reused without Customer. However, Customer doesn't need to know about Flight, so Customer can be easily reused. Any class that has many unidirectional relationships coming out of it is hard to reuse; any class that has only unidirectional relationships coming into it is easy to reuse, as shown in Figure 8.8.
Figure 8.8: Reuse with unidirectional associations
When you generate code for a bidirectional association, Rose will generate attributes in each class. In our Flight and Customer example, Rose will place a Flight attribute inside Customer, and a Customer attribute inside Flight. Figure 8.9 is an example of the code generated for these two classes.
305
![](/html/1334/288/html_hMM93oGmoc.litP/htmlconvd-5UmcB1318x1.jpg)
Chapter 8: Relationships
Figure 8.9: Code generated for a bidirectional association
If, instead, we have a unidirectional association, Rose will place a Customer attribute inside Flight, but not a Flight attribute inside Customer. Figure 8.10 is an example of the code generated for a unidirectional association.
Figure 8.10: Code generated for a unidirectional association
Associations can also be reflexive. A reflexive association suggests that one instance of a class is related to other instances of the same class. For example, we may have a Person class. One person can be the parent of one or more other people. Because there are separate instances of Person with a relationship to each other, we have a reflexive association, as shown in Figure 8.11.
Figure 8.11: Reflexive association
Using Web Association Stereotypes
With the inclusion of web modeling, Rose now supports four stereotypes for associations. These are the link, submit, build, and redirect stereotypes.
The link stereotype is used to show a hypertext link between two client pages or from a client page to a server page. It is represented on a Class diagram as a unidirectional association with a stereotype of <<link>>:
306
![](/html/1334/288/html_hMM93oGmoc.litP/htmlconvd-5UmcB1319x1.jpg)
Chapter 8: Relationships
The submit stereotype is used when a form sends the information in its fields to a server page for processing. This submittal of information is shown on a Class diagram as a unidirectional association relationship with a stereotype of <<submit>>.
The build stereotype is used when a server page builds a client page. Once the client page has been built, it can be displayed on the client browser. The relationship shows which server page builds which client page. It is shown on a class diagram as a unidirectional relationship with a stereotype of <<build>>:
Finally, the redirect stereotype is used to show one page passing processing control to another page. A redirect relationship is shown as a unidirectional association with a stereotype of <<redirect>>:
Creating Associations
In Rose, you create associations directly on a Class diagram. The Diagram toolbar includes buttons for creating both unidirectional and bidirectional associations.
If you create a bidirectional association, you can later change it to a unidirectional association by changing its navigability. Later in this chapter, in the "Working with Relationships" section, we will discuss the detailed specifications of an association, including navigability.
To create a bidirectional association on a Class diagram:
1.
307
Chapter 8: Relationships
Select the Association icon from the toolbox.
2.
Drag the association line from one class to the other class.
OR
1.
Select Tools → Create → Association.
2.
Drag the association line from one class to the other class.
To create a unidirectional association on a Class diagram:
1.
Select the Unidirectional Association icon from the toolbox.
2.
Drag the association line from one class to the other class.
OR
1.
Select Tools → Create → Unidirectional Association.
2.
Drag the association line from one class to the other class.
To set the navigability of a relationship:
1.
Right−click the desired relationship at the end to be navigated.
2.
Select Navigable from the menu.
OR
1.
Open the desired relationship's specification window.
2.
Select the Role Detail tab for the end to be navigated.
3.
Change the navigability using the Navigable check box.
To create a reflexive association on a Class diagram:
1.
308
Chapter 8: Relationships
Select the Association icon from the toolbox.
2.
Drag the association line from the class to somewhere outside of the class.
3.
Release the association line.
4.
Drag the association line back into the class.
OR
1.
Select Tools → Create → Association.
2.
Drag the association line from the class to somewhere outside of the class.
3.
Release the association line.
4.
Drag the association line back into the class.
To add documentation to an association:
1.
Double−click the desired association.
2.
Select the General tab.
3.
Enter documentation in the Documentation field.
OR
1.
Select the desired association.
2.
Select Browse → Specification.
3.
|
Select the General tab. |
4. |
|
|
Enter documentation in the Documentation field. |
To change a relationship to an association: |
|
1. |
309 |