UML and its Use-Case UML and its Use-Case ModelingModeling
Professor Chen
School of Business
Gonzaga University
Spokane, WA 99258
UML (Use-Case Modeling), Dr. ChenTM -2
Methods vs. Modeling LanguagesMethods vs. Modeling Languages
A model has its purpose of structuring our thoughts
A method– is an explicit way of structuring one’s
thinking and actions– tells us:
• What to do• How to do it• When to do it• Why it’s done
UML (Use-Case Modeling), Dr. ChenTM -3
Method, Modeling Language Method, Modeling Language and Processand Process
METHOD = +
Modeling Language
PROCESS
UML (Use-Case Modeling), Dr. ChenTM -4
Process vs. MethodProcess vs. Method
A process is a group of activities that, if done correctly, will achieve an explicit goal.
A method, in contrast, is normally also considered as a set of related activities, but without explicit goals, resources, and rules.
UML (Use-Case Modeling), Dr. ChenTM -5
What is a Process?What is a Process?
ProcessResourcesDocumentation,
Products, Models
etc.Humans,
computers
tools,
Information
What to do,
How to do it,
When to do it,
Why it should be done
Rules<<Util
ize>> [VALUE]
UML (Use-Case Modeling), Dr. ChenTM -6
What is a Process?What is a Process?
ProcessResources Documentation,
Products, Models
etc.Humans,
computers
tools,
Information
What to do,
How to do it,
When to do it,
Why it should be done
Rules
<<Utilize>>
[VALUE]Software Development:
Process CONTEXT,
USER, STEPS
A process is a group of activities that, if done correctly, will achieve an explicit goal.
UML (Use-Case Modeling), Dr. ChenTM -7
What is the UML?What is the UML? The Unified Modeling Language (UML)
is a graphical language for visualizing, specifying, constructing, and documenting the artifacts of a software-intensive systems.
UML is only a modeling language without a process– it is a lot easier to comprehend than a
natural language
UML (Use-Case Modeling), Dr. ChenTM -8
What does UML give you?What does UML give you?
The UML gives you a standard way to write a system’s blueprints covering conceptual things, such as business processes and system functions, as well as concrete thins, such as classes written in a specific programming language, database schemas, and reusable software components.
UML (Use-Case Modeling), Dr. ChenTM -9
How Applicable of UML?How Applicable of UML?
The UML is applicable to anyone involved in the production, deployment, and maintenance of software.
UML (Use-Case Modeling), Dr. ChenTM -10
What is Visual Modeling?What is Visual Modeling?
VISUAL MODELING is a way of thinking about problems using (graphical) models organized around real-world idea.
UML is a product of VISUAL MODELING language.
UML (Use-Case Modeling), Dr. ChenTM -11
Models are useful for ..Models are useful for ..
understanding problems, communicating with everyone involved
with project (customer, domain experts, analysts, designers, etc.)
modeling enterprise, preparing documentation, and designing programs and databases
UML (Use-Case Modeling), Dr. ChenTM -12
Objectives of the ModelingObjectives of the Modeling
Modeling promotes: better understanding of requirements, cleaner designs, and more maintainable systems.
UML (Use-Case Modeling), Dr. ChenTM -13
What is a Good Model?What is a Good Model?
A model is good when:
it is a relevant model it is possible to communicate it fits its purpose it captures the essentials
UML (Use-Case Modeling), Dr. ChenTM -14
System Boundary
Use Case ACTOR
(Role)<deli
ver tan
gible valu
e to>
Customer Statistics
Sales Statistics
Signing an insurance policy
<send> <receive>
<initiate>
<communicate>
Figure: A Use-Cases Example
UML (Use-Case Modeling), Dr. ChenTM -15
Purposes of the Use-Case Purposes of the Use-Case ModelingModeling
What a new system should do What an existing system already does
UML (Use-Case Modeling), Dr. ChenTM -16
What is an Actor?What is an Actor?
An actor is a class not an instance. It represents a role, not an individual
user of the system. primary vs. secondary actors
– customer/user, developer, test teams vs. manager or board members
active vs. passive
UML (Use-Case Modeling), Dr. ChenTM -17
Return books
Interlibrary loan
Borrow books
Library
Member
Figure: An Library Use-Cases Example
Do research
Read books, newspaper
Purchase supplies
Circulation Clerk
Supplier
UML (Use-Case Modeling), Dr. ChenTM -18
SummarySummary Use-case modeling is a technique used to
describe the functional requirements of a system A use case is a set of sequence of actions
performed in the system. A scenario is an illustration or an example
(instance) of a use case or collaboration. An actor represents a role that an external entity
(user, hardware) plays in interacting with the system.
UML (Use-Case Modeling), Dr. ChenTM -19
Insurancecompany
Insurance contract
Customer
1 0..*
0..*
1..*Figure 4.1: A simple mode of an insurance business. One insurance company hasmany (zero-to-many) insurance contracts. An insurance customer has many (zero-to-many) insurance contracts. Aninsurance contract is related to one insurance company. The insurance contract is related to many (one-to-many) insurance customers. The entities shown in the model are classes.
Figure 4.1: A simple mode of an insurance business. One insurance company hasmany (zero-to-many) insurance contracts. An insurance customer has many (zero-to-many) insurance contracts. Aninsurance contract is related to one insurance company. The insurance contract is related to many (one-to-many) insurance customers. The entities shown in the model are classes.
UML (Use-Case Modeling), Dr. ChenTM -20
Figure 4.2 A Class in UML
Attributes
Operations
Name
UML (Use-Case Modeling), Dr. ChenTM -21
Car
registration number dataspeed direction
Figure 4.3 A class car with the attributes registration number, data, speed, and direction. Attribute names typically begin with a lowercase letter
UML (Use-Case Modeling), Dr. ChenTM -22
Car
registration number: Stringdata: CarDataspeed: integerdirection: Direction
Figure 4.4 The car with typed attributes
Invoice
+amount : Real+ date: Date + customer: String+specification: String-administrator: String
Figure 4.5: A class with public and private attributes
UML (Use-Case Modeling), Dr. ChenTM -23
Invoice
+amount : Real+ date: Date=Current date+ customer: String+specification: String-administrator: String=“Unspecified”
Figure 4.6 A class with attributes and their default values
UML (Use-Case Modeling), Dr. ChenTM -24
Invoice
+amount : Real+date: Date=Current date+customer: String
-number_of_invoices: integer = 0
Figure 4.9 An Invoice class
Public class Invoice{ public double amount; public Date date = new Date(); public String customer; static private int number_of_invoices = 0; //Constructor, called every time an objects is created public Invoice () { // Other Initialization number_of_invoices++; //Increment the class attributes } // Other methods go here};
UML (Use-Case Modeling), Dr. ChenTM -25
Car
+ registration number: String+ data: CarData+ speed: integer+ direction: Direction
+ drive (speed: integer, direction: Direction)+ getData() : CarData
Figure 4.10 The car has attributes and operations. The operation drive has two parameters, speed and direction. The operation getData has a return type, CarData.
UML (Use-Case Modeling), Dr. ChenTM -26
Author Computer
Figure 4.15 An author uses a computerThe author class has an association to theComputer class.
Figure 4.15 An author uses a computerThe author class has an association to theComputer class.
Uses
Associations: Normal Association
UML (Use-Case Modeling), Dr. ChenTM -27
Person Car0..*
Figure 4.16 A person owns many (zero-to-many) cars,A car can be owned by many (one-to-many) persons.
Figure 4.16 A person owns many (zero-to-many) cars,A car can be owned by many (one-to-many) persons.
1..* Owns
Owned by
UML (Use-Case Modeling), Dr. ChenTM -28
Person Car0..*
Figure 4.17 A navigable association says that a person can own many cars, but it does not say anything about how many people can own a car.
Figure 4.17 A navigable association says that a person can own many cars, but it does not say anything about how many people can own a car.
Owns
UML (Use-Case Modeling), Dr. ChenTM -29
Insurancecompany
Insurance contract
1 0..*
0..*
Customer
1..*
Insurance policy
WebInsurance
policy0..1
0..1is expressed in an
Expressed
an
hasrefer to
has
refer to
Figure 4.18 A class diagram describing
an insurance business
Figure 4.18 A class diagram describing
an insurance business
UML (Use-Case Modeling), Dr. ChenTM -30
Author
name : Stringage: Integer
0..* 1..*
Computer
name : Stringmoney: Integer
Bob:Author
name : Stringage: Integer
0..* 1..*
Bob’s PC COMPUTER
name : Stringmoney: Integer
Figure4.19 A class diagram and an object diagram and an example of the class diagram being instantiated
UML (Use-Case Modeling), Dr. ChenTM -31
Node
Connects
Recursive Association
Figure 4.20 A network consists of many nodesconnected to each other.
Figure 4.20 A network consists of many nodesconnected to each other.
Person
married to
UML (Use-Case Modeling), Dr. ChenTM -32
Insurance contract
Insurancecompany
1 0..*
refer to
contracts
Figure 4.22 Insurance company hasassociations to Insurance contract
Figure 4.22 Insurance company hasassociations to Insurance contract
UML (Use-Case Modeling), Dr. ChenTM -33
Car Person
Figure 4.24 What roles do Person and Car play in this association?
Figure 4.24 What roles do Person and Car play in this association?
Another example of Roles in Association
drives **
drivercompany car
UML (Use-Case Modeling), Dr. ChenTM -34
Person
married to
wife
husband
Figure 4.25 A husband is married to a wife. Both husband and wifeare people. If a person is not married, then he or she cannot play
the role of husband or wife, which means that the married toassociation is no applicable.
Figure 4.25 A husband is married to a wife. Both husband and wifeare people. If a person is not married, then he or she cannot play
the role of husband or wife, which means that the married toassociation is no applicable.
Roles in Association
UML (Use-Case Modeling), Dr. ChenTM -35
Ready for the Next Run?Ready for the Next Run?
UML (Use-Case Modeling), Dr. ChenTM -36
Insurance contract
0..*
0..*
Insurance policy
0..1
is expressed in an
Expressed an
Insurancecompany
1 has
refer to
1..*
has
refer to
insurer
Person
policyholder
husband
married to
wife
Figure 4.26 A class can play different roles in different associations. The model fromFigures 4.18 and 4.25 are combined. In this model, a person can play the role ofhusband, wife, or policyholder. The insurance company plays the insurer role.
Figure 4.26 A class can play different roles in different associations. The model fromFigures 4.18 and 4.25 are combined. In this model, a person can play the role ofhusband, wife, or policyholder. The insurance company plays the insurer role.
Roles in an Association
UML (Use-Case Modeling), Dr. ChenTM -37
FileDirectory file name*
An example for Qualified Association
FileDirectory**
UML (Use-Case Modeling), Dr. ChenTM -38
Insurance contract
0..*
Insurancecompany
1 0..*
1..*
Person Company
1..*
0..*
Figure 4.28 An insurance contract cannot have associations to both company and person at the same time
Figure 4.28 An insurance contract cannot have associations to both company and person at the same time
Or-Association
UML (Use-Case Modeling), Dr. ChenTM -39
Insurance contract
0..*
Insurancecompany
1 0..*
1..*
Person Company
1..*
0..*
Figure 4.29 An or-association shows that only oneof the associations is valid at a time
Figure 4.29 An or-association shows that only oneof the associations is valid at a time
Or-Association
or
UML (Use-Case Modeling), Dr. ChenTM -40
0..*
1..*
Insurance contract
Insurancecompany
1 0..*has
refer toinsurer
Results of Figures 4.26, 28, and 29: An insurance contract cannot have associations to both company and person at the same time
Results of Figures 4.26, 28, and 29: An insurance contract cannot have associations to both company and person at the same time
Company
0..*
1..*
0..*
has
refer toPerson
policyholder
husband
married to
wife
1..*
Or-Association
or
UML (Use-Case Modeling), Dr. ChenTM -41
Insurance contract
0..*
0..*
Insurancecompany
1
1..*
Person
Figure 4.32 A ternary association connects three classes.Figure 4.32 A ternary association connects three classes.
Insurance policy
0..1
policyholder
insurer
UML (Use-Case Modeling), Dr. ChenTM -42
Teams Person*
Members
Figure 4.34 A team is composed of team Members. One person could be a member of many teams. The model shows an example of a shared aggregation, where the people are the shared parts.
Figure 4.34 A team is composed of team Members. One person could be a member of many teams. The model shows an example of a shared aggregation, where the people are the shared parts.
*
UML (Use-Case Modeling), Dr. ChenTM -43
Window
Text*
Listbox*
Button*
Menu*
Figure 4.36 The diamond shows the composition aggregate; the window contains ( is aggregated of) many menus, buttons, listboxes, and texts. All types of aggregation can have a name.
UML (Use-Case Modeling), Dr. ChenTM -44
Window
Text*
Listbox*
Button*
Menu*
Figure 4.37 If there is more than one part in the same aggregate (wholeside into a single end.This is allowed for all types of aggregates. An aggregate has only one role name, and that is at the partside.
Contains
UML (Use-Case Modeling), Dr. ChenTM -45
Vehicle
CAR Boat Truck
Figure 4.41 Vehicle is a general class (superclass) derived to specific classes (subclasses) via inheritance (generalization-specialization).
UML (Use-Case Modeling), Dr. ChenTM -46
Vehicle
CAR Boat Truck
Figure 4.42 The same model as in Figure 4.41, but the inheritance takes the form of a tree (with only one hollow triangle).
UML (Use-Case Modeling), Dr. ChenTM -47
Vehicle
CAR Boat Truck
Vehicle
CAR Boat Truck
Vehicle
Figure 4.43 A class hierarchy for vehicles. The Car class is subclass to Vehicle, but superclass to Sports car, Passenger car, and Truck.
UML (Use-Case Modeling), Dr. ChenTM -48
Vehicle {abstract}
Drive() {abstract}
Car
drive()
Boat
drive()
drive() startsthe wheels
drive() startsthepropeller
Figure 4.44 The Car inherits the attribute color and the operation drive. The operation drive is redefined in the class Car and Boat. The class Vehicle is abstract, which also is marked. The notes below the classes are used to comment on a class diagram
Figure 4.44 The Car inherits the attribute color and the operation drive. The operation drive is redefined in the class Car and Boat. The class Vehicle is abstract, which also is marked. The notes below the classes are used to comment on a class diagram
UML (Use-Case Modeling), Dr. ChenTM -49
drives
Vehicle {abstract}
colordrive() {abstract}
Car
drive()
Boat
drive()
*Person
Figure 4.45 A person drives vehicles.When the drive operation is called, the implementation used depended on whether the object used is a car or a boat. Vehicle is an abstract class showing the commonalties between cars and boats, including the association relationship to the Person class
Figure 4.45 A person drives vehicles.When the drive operation is called, the implementation used depended on whether the object used is a car or a boat. Vehicle is an abstract class showing the commonalties between cars and boats, including the association relationship to the Person class
UML (Use-Case Modeling), Dr. ChenTM -50
Vehicle {abstract}
drive() {abstract}
Car
drive()
Boat
drive()
Propulsion Propulsion
Figure 4.47 Generalization-specialization with a discriminator that specifies that it is with respect to the propulsion that the subclass differ.
UML (Use-Case Modeling), Dr. ChenTM -51
Object vs. Function-Oriented Analysis and Design
(Structured Analysis and Design)
The Library Information system
Object-oriented A/D
Decomposed by objects
or concepts
Structured A/D
Decomposed by functions
or processes
LibrarianCatalogue
LibraryBook
System
RecordLoans
AddResource
ReportFines
UML (Use-Case Modeling), Dr. ChenTM -52
Figure: Conventional vs. Object - Oriented
Conventional Object-OrientedDecomposed by
Functions/process Objects/concepts
Types Data type
(e.g.) int num_of_employees
Class type class employee … }employee full-time, part-time;
Content One variable
contains one value.
e.g. number_of _employees
=20
One class containsmany objectsOne objecthas many attributes, operations