- •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
Chapter 4: Use Cases and Actors
Use cases and actors define the scope of the system you are building. Use cases include anything that is within the system; actors include anything that is external to the system. We'll start this chapter by discussing some of the fundamental concepts of use case, or system, modeling: use case, actor, association relationship, includes relationship, extends relationship, generalization relationship, flow of events, activity diagram, and Use Case diagram. Then, we'll look at how to model each of these in Rose.
At the end of the chapter, we provide an exercise that builds on the business case of Chapter 3, "Business Modeling," by adding use cases, actors, and Use Case diagrams to a Rose model.
∙
Using the Use Case view and Use Case diagrams
∙
Working with use cases, actors, and relationships
∙
Using notes
∙
Adding and deleting Use Case packages
Use Case Modeling Concepts
In this section, we'll discuss some of the fundamental concepts of use case modeling: use cases, actors, relationships, activity diagrams, and Use Case diagrams. If you have gone through the business modeling process, you will notice the similarities between what we will discuss here and business modeling. Business modeling also works with actors, use cases, relationships, activity diagrams, and Use Case diagrams. The difference is that business modeling focuses on the organization, while system modeling focuses on the system being built. The terms system use case or system actor are sometimes used to differentiate them from business use cases or business actors.
Item |
Business Modeling |
System Modeling |
Use case |
Describes what the business does |
Describes what a system within the |
|
|
business does |
Actor |
External to the organization |
External to the system (may be |
|
|
internal to the organization) |
Business worker |
Internal to the organization |
Not used |
In the last chapter, we went through the business modeling process for an airline. During that example, we focused on the business of being an airline, not on what systems we would build. Now, we focus in on a particular system. Assume that we are building a ticket reservation system for the airline. It will eventually let people call in or go online to order plane tickets and to change or cancel a reservation.
Actors
An actor is anyone or anything that interacts with the system being built. As we will see shortly, use cases describe anything that is inside the system's scope. Actors are anything that is outside the system's scope. In
104
Chapter 4: Use Cases and Actors
UML, actors are represented with stick figures:
There are three primary types of actors: users of the system, other systems that will interact with the system being built, and time.
The first type of actor is a physical person, or a user. These are the most common actors, and are present in just about every system. For our flight reservation system, actors are the people who will be directly using the system. Because we know some of the functionality will be available over the Internet, customers can directly use the system. We also know that customers can call in to a customer service representative to make a reservation. The customer service representative will directly use the system, so this role is an actor as well.
When naming actors, remember to use role names rather than position names. A given individual will play many roles. John Doe may be a customer service representative, but if he goes online to buy a ticket for himself, he is playing the role of a customer. Using role names rather than position names will give you a more stable picture of your actors. Position names change over time, as roles and responsibilities are moved from one position to another. By using roles, you won't need to update your model every time a new position is added or a position changes.
The second type of actor is another system. For example, the airline's reservation system may need to interface with an external application to validate credit cards for purchases. In this example, the external credit application is an actor. It is another system that we won't be changing at all, so it is outside the scope of the current project, but it does need to interface with our new system. Any systems like this, which lie just beyond the boundaries of our application, are actors.
The third type of actor that is commonly used is time. Time becomes an actor when the passing of a certain amount of time triggers some event in the system. For example, part of our airline's promotions may be the chance to win a free ticket. Every day at 3:00 p.m. the system may automatically select a random customer to give a free ticket to. Because time is outside of our control, it is an actor.
Use Cases
A use case is a high−level piece of functionality that the system will provide. In other words, a use case illustrates how someone might use the system. Let's begin by looking at an example.
Along with our actors, we need to define the use cases for the airline reservation system. It really doesn't matter if you identify the use cases or the actors first. In fact, these two steps are usually done together. To identify the use cases, we answer the question: What will the system do that provides value to the outside world? We can see from our brief vision statement above that it will let users purchase tickets, change a reservation, or cancel a reservation. These are all good candidates for use cases; each is some piece of functionality the system will provide that is of value to the end user. Notice that we didn't include a use case, such as "Get Flight Information" from the legacy system. This is a behind−the−scenes piece of logic that the end user really doesn't care about, so it doesn't qualify as a use case. "Purchase Ticket," "Change Reservation," or "Cancel Reservation," on the other hand, are things that the end user would care about and high−level pieces of functionality the system will provide, so they are good use cases. In UML, a use case is
105
Chapter 4: Use Cases and Actors
represented by the following symbol:
The advantage of looking at a system with use cases is the ability to dissociate the implementation of the system from the reason the system is there in the first place. It helps you focus on what is truly important—meeting the customer's needs and expectations without being instantly overwhelmed by implementation details. By looking at the use cases, the customer can see what functionality will be provided, and can agree to the system scope before the project goes any further.
Use cases take a different approach than traditional methods. Splitting the project into use cases is a process−oriented, not an implementation−oriented, way of looking at the system. It is therefore different from the functional decomposition approach that is so often taken. While functional decomposition focuses on how to break the problem down further and further into pieces that the system will handle, the use case approach focuses first on what the user expects from the system.
When you are beginning a project, a natural question is: How do I go about finding the use cases? A good way to begin is to examine any documentation the customers have provided. For example, a high−level scope or vision document can frequently help you identify the use cases. Consider also each of the stakeholders of the project. Ask yourself what functionality each stakeholder expects from the system. For each stakeholder, ask questions such as:
∙
What will the stakeholder need to do with the system?
∙
Will the stakeholder need to maintain any information (create, read, update, delete)?
∙
Does the stakeholder need to inform the system about any external events?
∙
Does the system need to notify the stakeholder about certain changes or events?
As we mentioned before, use cases are an implementation−independent, high−level view of what the user expects from the system. Let's examine each piece of this definition separately.
First, the use cases are implementation−independent. As you are defining the use cases, assume you are building a manual system. Your use cases should be able to be built in Java, C++, Visual Basic, or on paper. Use cases focus on what the system should do, not how the system will do it. We'll get into the how later on in the process.
Secondly, the use cases are a high−level view of the system. Your collection of use cases should let the customers easily see, at a very high level, your entire system. There should not be so many use cases that the customer is forced to wade through pages and pages of documentation just to see what the system will do. At the same time, there should be enough use cases to completely describe what the system will do. A typical system will have somewhere between 20 and 70 use cases. (If your system has 3000 use cases, you've lost the benefit of simplicity.) You can use different types of relationships, called includes and extends relationships,
106
Chapter 4: Use Cases and Actors
to break down the use cases a little if you need to. You can also package the use cases together to form groups of use cases to help you organize them better. We'll explore these topics later in this chapter.
Finally, the use cases should be focused on what the user will get out of the system. Each use case should represent a complete transaction between the user and the system that results in something of value to the user. The use cases should be named in user terms, not technical terms, and should be meaningful to the customer. We wouldn't have a use case, for example, called "Interface with the Bank's Credit System to Validate the Credit Card Number." The customer is trying to purchase a ticket, so that's what we call the use case: "Purchase Ticket." Use cases are typically named with verbs or short verb phrases in the format "<verb> <noun>," and describe what the customer sees as the end result. The customer doesn't care how many other systems you have to interface with, what specific steps need to be taken, or how many lines of code you need to confirm a Visa card. That customer cares only that a ticket was purchased. Again, you focus on the result the user expects from the system, not the steps that were taken to achieve the result.
So, when you have the final list of use cases, how do you know if you've found them all? Some questions to ask are:
∙
Is each functional requirement in at least one use case? If a requirement is not in a use case, it will not be implemented.
∙
Have you considered how each stakeholder will be using the system?
∙
What information will each stakeholder be providing for the system?
∙
What information will each stakeholder be receiving from the system?
∙
Have you considered maintenance issues? Someone will need to start the system and shut it down.
∙
Have you identified all of the external systems with which the system will need to interact?
∙
What information will each external system be providing to the system and receiving from the system?
Traceability
As with business modeling, a very important concept to consider at this point is traceability. Each of the system use cases should be able to be traced back to a business use case. The system use case is what implements part of the functionality in the business use case.
This is not a one−to−one mapping. Business use cases tend to be very high level, so many system use cases may be needed to support a single business use case. For example, an airline has a business use case called "Repair Plane." If we build a system to support this use case, it will have a lot of system use cases in it, such as "Enter Problem," "Check Inventory for Available Parts," "Receive Part from Inventory," "Order Part," "Schedule Maintenance," and so on. Each of these system use cases would be traced to the business use case
107