Anda di halaman 1dari 12

Before the UML

1960s - 70s

OO Analysis Use Case Modeling


User Requirements Modeling

- COBOL, FORTRAN, C - Structured analysis and design techniques

1980s - early 1990s


- Smalltalk, Ada, C++, Visual Basic - Early generation OO methods

Mid/late 1990s
Java UML Unified Process Collaborative software process (open source)
jzavalar@yahoo.com
2

By Jesus Zavala jzavalar@yahoo.com

The Value of the UML


Is an open standard Supports the entire software development lifecycle Supports diverse applications areas Is based on experience and needs of the user community Supported by many tools

Creating the UML


OMG Acceptance, Nov 1997 Final submission to OMG, Sep 97 public feedback First submission to OMG, Jan 97 UML partners Web - June 96 OOPSLA 95

UML 2 UML 1.3, 1.4 UML 1.1 UML 1.0 UML 0.9

Unified Method 0.8

Other methods

Booch method

OMT

OOSE

jzavalar@yahoo.com
3 4

jzavalar@yahoo.com

Contributions to the UML


Meyer
Before and after conditions

Overview of the UML


Gamma, et al
Frameworks and patterns,

Harel
Statecharts

The UML is a language for


HP Fusion

Booch
Booch method

Operation descriptions and message numbering

Rumbaugh
OMT

Embley
Singleton classes and high-level view

visualizing specifying constructing documenting

the artifacts of a software-intensive system

Jacobson
OOSE

Wirfs-Brock
Responsibilities

Shlaer - Mellor
Object lifecycles

Odell
Classification

jzavalar@yahoo.com
5 6

jzavalar@yahoo.com

Architecture and the UML

Workflows and Models


UML diagrams provide views into each model
Requirements Use Case Model

Design View
Classes, interfaces, collaborations

Implementation View
Analysis

Analysis Model

Use cases

Components
Design Design Model Depl. Model

Use Case View Process View Deployment View

Implementation

Impl. Model

Active classes

Nodes

Test

Test Model

Organization Package, subsystem


7

Dynamics Interaction State machine

jzavalar@yahoo.com

Each workflow is associated with one or more models.


8

jzavalar@yahoo.com

Analysis & Design Model


Use Case Diagrams
Use Case Model

User requirements
Functional requirements
Object Diagrams Class Diagrams Component Diagrams Deployment Diagrams Sequence Diagrams Collaboration Diagrams Statechart Diagrams Activity Diagrams

Use Case Diagrams


Actors Use Cases graphical Use Cases textual Test Use Cases Glossary

Analysis Model

Incl. subsystems and packages

Design Model

Depl. Model

Impl. Model

Prototypes

Test Model

jzavalar@yahoo.com
10

jzavalar@yahoo.com

Use Case Diagram


Captures system functionality as seen by users Built in early stages of development Purpose
Specify the context of a system Capture the requirements of a system Validate a systems architecture Drive implementation and generate test cases

Use Case Diagram


Captures system functionality as seen by users

Developed by analysts and domain experts


jzavalar@yahoo.com
11 12

jzavalar@yahoo.com

Use case diagram elements


Use Case Actor

Use Case Diagram Example

Identify Movie

Customer

Open Account

Clerk

Return Movie

In-Store Customer

Telephone Customer

Review Account Status

jzavalar@yahoo.com
13 14

jzavalar@yahoo.com

Use Case Text Format


R F - < id d e l r e q u is i to > V e r s i n A u to re s F u e n te s O b je ti v o s a s o c ia d o s D e s c r ip c i n < n o m b r e d e l r e q u is ito f u n c io n a l> < n u m e r o d e v e r s i n y f e c h a > < a u t o r> < f u e n t e d e la v e r s i n a c t u a l> < n o m b r e d e l o b je t iv o > E l s is t e m a d e b e r c o m p o r t a r s e t a l c o m o s e d e s c r ib e e n e l s ig u ie n t e c a s o d e u s o { c o n c r e t o c u a n d o < e v e n t o d e a c t iv a c i n > , a b s t r a c t o d u r a n t e la r e a liz a c i n d e lo s c a s o s d e u s o < lis t a d e c a s o s d e u s o > } < p r e c o n d ic i n d e l c a s o d e u s o > Pa so A c c i n 1 { E l < a c t o r > , E l s is t e m a } < a c c i n r e a liz a d a p o r e l a c t o r o s is t e m a > , s e r e a liz a e l c a s o d e u s o < c a s o d e u s o R F -x > 2 S i < c o n d ic i n > , { e l < a c t o r > , e l s is t e m a } < a c c i n r e a liz a d a p o r e l a c t o r o s is t e m a > > , s e r e a liz a e l c a s o d e u s o < c a s o d e u s o R F -x > 3 4 5 6 n < p o s t c o n d ic i n d e l c a s o d e u s o > Pa so A c c i n 1 S i < c o n d ic i n d e e x c e p c i n > , { e l < a c t o r > , e l s is t e m a } } < a c c i n r e a liz a d a p o r e l a c t o r o s is t e m a > > , s e r e a liz a e l c a s o d e u s o < c a s o d e u s o R F - x > , a c o n t in u a c i n e s t e c a s o d e u s o { c o n t in u a , a b o r t a } 2 3 Pa so C o t a d e tie m p o 1 n segund os 2 n segund os < n d e v e c e s > v e c e s / < u n id a d d e t ie m p o > { s in im p o r t a n c ia , im p o r t a n t e , v it a l} { p u e d e e s p e r a r , h a y p r e s i n , in m e d ia t a m e n t e } < c o m e n t a r io s a d ic io n a le s >

UC: Scenario based requirements modeling

P r e c o n d ic i n S e c u e n c ia N o rm a l

Recommended: Booch, Rumbaugh, Jacobson: The Unified Modeling Language User Guide. Addison Wesley, 1999

P o s tc o n d ic i n E x cep cio n es

R e n d im ie n to

F r e c u e n c ia e s p e r a d a Im p o r t a n c ia U rg en cia C o m e n t a r io s

jzavalar@yahoo.com
15 16

jzavalar@yahoo.com

Use Case 1
Specifies the intended behavior (the what?) of a system. Is a set of sequences of actions (including variants) to yield an observable result of value to an actor. Represents a functional requirement of the system as a whole. It IS NOT a flow chart

Use Case 2 Each sequence (also called a scenario) represents the interaction of things outside the system (its actors) with the system itself (or parts of the system). Separate main vs. alternative flows
Use case
Process loan Loan Officer

Used to: describe customer requirements (early analysis). Validate your architecture / verify your system.
jzavalar@yahoo.com
17

Actor

jzavalar@yahoo.com
18

Use Case Example


Name: Capture deal Precond: Financial Officer is logged in Main flow of events: 1. Enter the client name & bank account 2. Check that they are valid 3. Enter number of shares to buy & share ID 4. Determine price 5. Check limit 6. Prepare order to NYSE 7. Store confirmation number and give it to client jzavalar@yahoo.com
19

Use cases: terms and concepts


Unique name
e.g.: Place order, Validate user

Sequence of actions (event flows)


- textual (informal, formal, semi formal)
Main flow of events: The use case starts when the system prompts the Customer for a PIN number. The Customer can now enter a pin number... Exceptional flow of events: If the Customer enters am invalid PIN number

Client Capture deal Financial Officer

- interaction diagrams

jzavalar@yahoo.com
20

Actors
Role that a human/hardware device/ another system plays with respect to the system Actors carry out use cases
- look for actors, then their use cases

Actors
Actors can be specialized
specialization relationship

Officer Loan Officer

Actors do not need to be humans! Actors can get value from the use case (Client in example) or participate in it (Financial Officer in example)

connected to use cases only by association association = communication relationship (both can send messages to, or receive messages from the other one)
jzavalar@yahoo.com
22

jzavalar@yahoo.com
21

Use case description


Generic, step-by-step written description of a use cases event flow
- Describe precondition (initial system state) - List sequence of steps

Organizing Use Cases: Generalization Relationship

child use case inherits behavior and meaning of the parent use case child may add or override the parents behavior
Validate client

Includes interactions with actor(s), and describes what objects are exchanged May contain extension points Clear, precise, short descriptions

Check password

Retinal scan

child may be substituted any place the parent appears

jzavalar@yahoo.com
23 24

jzavalar@yahoo.com

Organizing UC: Include Relationship


Used to avoid describing the same flow of events several times, by putting the common behavior in a use case of its own
<<include>>

Include Example
Use Case: Track order Precondition: Financial Officer is logged in Main flow:
1. Obtain and verify order number 2. Include (Validate client) 3. For each part in the order,

Place order
<<include>>

Validate client

Track order

Avoids copy & paste of parts of use case descriptions

jzavalar@yahoo.com
25 26

jzavalar@yahoo.com

Organizing UC: Extend relationship


Allows to model the part of a use case the user may see as optional
Place order Extension points: Set priority
<<extend>> (set priority)

Extend Example
Use Case: Place order Precondition: Financial Officer is logged in Main flow:
1. 2. Collect the clients order items 3. (set priority) 4. Submit order for processing

Allows to model conditional subflows Allows to insert subflows at a certain point, governed by actor interaction extension points (in textual event flows)

Place rush order

jzavalar@yahoo.com
27 28

jzavalar@yahoo.com

Using Extends relationship


Capture the base use case if we later delete extension points, we still have to have a use case achieving something! For every step ask
- - what could go wrong? - - how might this work out differently?

Comparing extends/includes
Different intent
- extend
to distinguish variants associated actors perform use case and all extensions actor is linked to base case

- include
to extract common behavior often no actor associated with the common use case different actors for caller use cases possible

Plot every variation as an extension of the use case

jzavalar@yahoo.com
29 30

jzavalar@yahoo.com

Extends and Includes Relationships


Dependency includes Find Item by Title Search Movie Database

A use case diagram


<<include>> Analyze risks <<include>> Price details Capture deal Limit exceeded <<extends>> Valuation

Includes
Customer

includes Find Items by Actor

Trader

Sales person

Stereotype

Extends
Clerk Check In Movie

extends Assess Late Fees

jzavalar@yahoo.com
31 32

jzavalar@yahoo.com

When and how


When: Requirements capture - first thing to do How: Use case: Every discrete thing your customer wants to do with the system
- give it a name - describe it shortly (some paragraphs) - add details later

Recipe / Tasks to do
Identify actors that interact with the system Organize actors Consider primary ways of interaction with actors Consider exceptional ways Organize behaviors as use cases, using generalize/include/extend relationships Describe what actors require from system, not what goes on in the system!
jzavalar@yahoo.com
33 34

jzavalar@yahoo.com

The End

Use Cases A Practical Example


Compiled by Jesus Zavala jzavalar@yahoo.com

Ski resort information system


Users should be able to query weather and snow condition forecasts for a date they enter. The system should allow to book single or double rooms at the resort hotel Skiers Luck online (with credit card). Visitors should be able to book one-day beginners courses on snowboards. There is only one course a day. The max. size of a course is 8 persons. The resort offers special courses for kids. In order to built courses with kids of same age, the customer has to enter the kids age. Canceling of course or room bookings are only possible up to 10 days ahead.

First Trying

jzavalar@yahoo.com
37 38

jzavalar@yahoo.com

Errors you should prevent 1!

Errors you should prevent 2!


Associations between actors Unnamed associations between use cases

<< includes >> stereotype in actor associations

jzavalar@yahoo.com
39 40

jzavalar@yahoo.com

Errors you should prevent 3!

Errors you should prevent 4!


Wrong understanding of the <<extends>> stereotype

System

no use case! Name relations!

jzavalar@yahoo.com
41 42

jzavalar@yahoo.com

Errors you should prevent 5!


Diagram moves main functionality outside the

Errors you should prevent 6!

system

Data structures instead of

functions as use cases, e.g. date, age, database relations not named
jzavalar@yahoo.com
43 44

jzavalar@yahoo.com

Example Use Case Diagram


Query weather&snow forecast Book room <<include>> Enter personal info <<include>>

Use Case 1
Use Case: Query weather&snow forecast Precond: Main flow:
1. Visitor enters date 2. Weather & snow forecast for local region is displayed for specified date

Visitor

Book SB course

Cancel course Cancel room

<<extend>> (Enter kids age) Book kids SB course

jzavalar@yahoo.com
45 46

jzavalar@yahoo.com

Use Case 2
Use Case: Book SB course Precond: Main flow:
1. 2. 3. 4. 5. Visitor enters date Include (Enter personal info) (Enter kids age) Store reservation Confirm reservation to Visitor

Use Case 3
Use Case: Book kids SB course Precond: SB course is for a kid Main flow:
1. 2. 3. Enter kids age Store reservation Confirm reservation to Visitor

Exceptional flow:
If course for specified date is adult course, then tell visitor so and let him choose another date.

Exceptional flow:
If number of course participants for specified date > 8, then tell visitor so and let him choose another date

Exceptional flow:
If course for specified date is kids course, and the specified age is outside the courses age range, then tell visitor so and let him choose another date.

jzavalar@yahoo.com
47 48

jzavalar@yahoo.com

Literature Reference Management System


Storage and retrieval of references, e.g.

Use Case Diagram: Lit Ref Mgmt Sys


Add reference

Title: The unified modeling language user guide Authors: G. Booch, J. Rumbaugh, I Jacobson Publisher: Addison Wesley Publication year: 1998 Title: Software engineering in the Internet age Authors: F. Maurer, G. Kaiser Publisher: IEEE Publication year: 1998 Journal: IEEE Internet Computing Magazine Volume: 2 Issue: 5

Small exercise: Draw a Use Case Diagram (at least two use cases) Describe use cases (at least one)

Remove reference

User Search for reference

List references

jzavalar@yahoo.com
49 50

jzavalar@yahoo.com

Event flow: List references


Precondition: user has selected list references functionality. The system prompts the user to select the device: printer or file. The system prompts the user to select the print order: by name or by title. The use case finishes with the system printing the list on the requested device.

Event flow: Add reference


Precondition: user has selected add new reference functionality. The system prompts the user to select if he/she wants to add a normal reference or a book. The system prompts the user to enter title, author, and publisher of the reference (Add journal paper) (Except-1). The user is notified that the reference has been successfully added. Except-1: The reference already exists. The user can re-enter the data or terminate the use case.

jzavalar@yahoo.com
51 52

jzavalar@yahoo.com

Use case: Add journal paper


<<extend>>

Add reference

Add journal paper

Use Case Example Elevator


By Jesus Zavala jzavalar@yahoo.com

Add journal paper: If the paper is a journal, then the system additionally asks for the journals name, the volume number and the issue number.

jzavalar@yahoo.com
53

Elevator -- Use Case


1 elevator, n floors

Example: Bank Account Manager


Use case for withdrawal Use case for depositing
Elevator

Use case for balance query


Small Test: Draw a Use Case Diagram (Organize use cases) Describe use cases

press an elevator button

press a floor button User

enter and exit through a door

jzavalar@yahoo.com
55 56

jzavalar@yahoo.com

Small Test: Bank Account Manager


System has to run on an automated teller machine. User must be able to deposit checks into the account. User must be able to draw money from the account. User should be able to query the balance of his/her account. The user should get a receipt for a transaction on request. The transaction type (withdrawal or deposit), the transaction date, the account number, the amount, and the new balance should be visible on the receipt. After each transaction the new balance should be displayed to the user.

Errors regarding arrows (connections)


connection between actors and use cases have no direction Connections between use cases are dotted ( ) and should be labeled <<extend>> or <<include>> <<extend>>: arrow points from use case describing the alternative event flow to the standard case <<include>>: arrow points from calling use case to use case that describes actions to include

jzavalar@yahoo.com
57 58

jzavalar@yahoo.com

Errors regarding relation graph & desc


If use cases are connected then in the textual description we have to mirror this:
- <<include>> - include (verify user) - <<extend>> - (print receipt) ...

Errors regarding textual desc of use cases


Preconditions not given No connection to graphical representation Different names in graphical and textual representation: user vs visitor use case name different bank info vs user info But also: use case name appearing several time in diagram

jzavalar@yahoo.com
59 60

jzavalar@yahoo.com

10

Other often occuring errors


Flow charts instead of use cases remember: use case = sequence of actions achieving a goal not: action = use case Exceptional flow: not only exception condition, but also actions if it occurs Exceptional flow: indicate in main flow at which point to check for this exception (if not obvious)!

Good solution 1
<<extend>> (print receipt) withdraw <<include>> check balance User <<include>> <<include>> withdraw with receipt

Verify user

deposit

<<extend>> (print receipt)

deposit with receipt

jzavalar@yahoo.com
61 62

jzavalar@yahoo.com

Good solution 2
Use case: withdraw Precondition: User has selected withdraw option Main flow: Include (Verify user) Prompt user for amount to withdraw Check available funds of user Check available money of ATM Remove amount from account Give money (print receipt) Print current balance Exceptional flow If not sufficient funds or money available, prompt user for lower amount
63

Good solution 3
Use case: deposit Precondition: User has selected deposit option Main flow: Include (Verify user) Prompt user for amount of deposit Open slot Get check (print receipt) Print (balance + deposited amount)
jzavalar@yahoo.com
64

jzavalar@yahoo.com

Good solution 4
Use case: check balance Precondition: User has selected balance option Main flow: Include (Verify user) Print balance

Good solution 5 (not required in test)


Use case: verify user Precondition: none Main flow: User enters ID card User enters PIN number System checks validity of card and number Exceptional flow: If combination is not valid, reject user
jzavalar@yahoo.com
65 66

jzavalar@yahoo.com

11

Good solution 6 (not required in test)


Use case: withdraw with receipt Precondition: User has selected withdraw option and print receipt option

Acceptable solution 1
<<extend>> (print receipt) withdraw

withdraw with receipt

check balance User

Use case: deposit with receipt Precondition: User has selected deposit option and print receipt option ...
deposit <<extend>> (print receipt) deposit with receipt

jzavalar@yahoo.com
67 68

jzavalar@yahoo.com

Acceptable solution 2
Use case: withdraw Precondition: User is verified and has selected withdraw option

The End

Similar for other use cases

jzavalar@yahoo.com
69

12

Anda mungkin juga menyukai