Aydoo 07 Usecase Modeling

  • Upload
    gil-ch

  • View
    226

  • Download
    0

Embed Size (px)

Citation preview

  • 8/4/2019 Aydoo 07 Usecase Modeling

    1/12

    OO AnalysisUse Case Modeling

    User Requirements Modeling

    By Jesus Zavala

    [email protected]@yahoo.com

    Before the UML

    1960s - 70s- 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)

    [email protected]

    The Value of the UML

    Is an open standard

    Supports the entire software developmentlifecycle

    Supports diverse applications areas

    Is based on experience and needs of theuser community

    Supported by many tools

    4

    [email protected]

    Creating the UML

    Booch method OMT

    Unified Method 0.8OOPSLA 95

    OOSEOther methods

    UML 0.9Web -June 96

    public

    feedback

    Final submission to OMG, Sep 97

    First submission to OMG, Jan 97

    UML 1.1

    OMG Acceptance, Nov 1997

    UML 1.3, 1.4

    UML 1.0UML partners

    UML 2

    [email protected]

    Meyer

    Before and after

    conditions

    Harel

    Statecharts

    Gamma, et al

    Frameworks and patterns,

    HP Fusion

    Operation descriptions and

    message numbering

    Embley

    Singleton classes and

    high-level view

    Wirfs-Brock

    Responsibilities

    Odell

    Classification

    Shlaer - Mellor

    Object lifecycles

    Rumbaugh

    OMT

    Booch

    Booch method

    Jacobson

    OOSE

    Contributions to the UML

    [email protected]

    Overview of the UML

    The UML is a language for

    - visualizing

    - specifying

    - constructing

    - documenting

    the artifacts of a software-intensive system

  • 8/4/2019 Aydoo 07 Usecase Modeling

    2/12

    [email protected]

    Architecture and the UML

    Organization

    Package, subsystem

    Dynamics

    Interaction

    State machine

    Design View Implementation View

    Process View

    ComponentsClasses, interfaces,

    collaborations

    Active classes

    Deployment View

    Nodes

    Use Case View

    Use cases

    [email protected]

    Workflows and Models

    Requirements

    Design

    Implementation

    Test

    Analysis

    Use CaseModel

    DesignModel

    Depl.Model

    Impl.Model

    AnalysisModel

    TestModel

    UML diagrams provideviews into each model

    Each workflow isassociated with one ormore models.

    [email protected]

    Analysis & Design ModelUse CaseDiagrams

    CollaborationDiagrams

    ComponentDiagrams

    DeploymentDiagrams

    ObjectDiagrams

    StatechartDiagrams

    SequenceDiagrams

    ClassDiagrams

    ActivityDiagrams

    Use CaseModel

    DesignModel

    Depl.Model

    Impl.Model

    AnalysisModel

    TestModel

    Incl. subsystemsand packages

    1

    [email protected]

    User requirements

    Functional requirements

    Use Case Diagrams

    - Actors

    - Use Cases graphical

    - Use Cases textual

    - Test Use Cases

    - Glossary

    Prototypes

    11

    [email protected]

    Use Case Diagram

    Captures system functionality as seen byusers

    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

    Developed by analysts and domain experts

    1

    [email protected]

    Use Case Diagram

    Captures system functionality as seen byusers

  • 8/4/2019 Aydoo 07 Usecase Modeling

    3/12

    1

    [email protected]

    Use case diagram elements

    TelephoneCustomer

    In-StoreCustomer

    Clerk

    Identify Movie

    Open Account

    Return Movie

    Customer

    ReviewAccount Status

    Actor

    Use Case

    14

    [email protected]

    Use Case Diagram Example

    1

    [email protected]

    Use Case Text FormatR F - < i d d e l r e q u i s i t o > < n o m b r e d e l r e q u i s i to f u n c i o n a l>V e r s i n < 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 e s < a u t o r >F u e n t e s < f u e n t e d e l a v e r s i n a c t u a l >O b j e t i v o s a s o c i a d o s < n o m b r e d e l o b j e t iv o >D e s c r i p c i n E l s i s t e m a d e b e r c o m p o r t a rs e t a l c o m o s e d e s c r i b e e n

    e l s i g 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 ea c t i v a c i n > , a b s t r a c t o d u r a n t e l a r e a l iz a c i n d e l o sc a s o s d e u s o < l i s ta d e c a s o s d e u s o > }

    P r e c o n d i c i n < p r e c o n d i c i n d e l c a s o d e u s o >P a s o 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 li z a d a p o r e la c t o r o s i s t e m a > , s e r e a l i z 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 i c i n > , { e l < a c t o r > , e l s i s t e m a } < a c c i nr e a l i z a d a p o r e l a c t o r o s i s t e m a > > , s e r e a l i z a e lc a s o d e u s o < c a s o d e u s o R F - x >

    3456

    S e c u e n c i aN o r m a l

    nP o s t c o n d i c i n < p o s t c o n d i c i n d e l c a s o d e u s o >

    P a s o A c c i n1 S i < c o n d i c i n d e e x c e p c i n > , { e l < a c t o r > , e l

    s i s t e m a } } < a c c i n r e a l i z a d a p o r e l a c t o r os i s t e m a > > , s e r e a l i z 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 i n u a c i n e s t e c a s od e u s o { c o n t i n u a , a b o r t a }

    2

    E x c e p c i o n e s

    3R e n d i m i e n to P a s o C o t a d e t ie m p o

    1 n s e g u n d o s2 n s e g u n d o s

    F r e c u e n c i a e s p e r a d a < n d e v e c e s > v e c e s / < u n i d a d d e t i e m p o >I m p o r t a n c i a { s i n i m p o r t a n c i a , i m p o r t a n t e , v i t a l }U r g e n c i a { p u e d e e s p e r a r , h a y p r e s i n , i n m e d i a ta m e n t e }C o m e n t a r i o s < c o m e n t a r i o s a d i c i o n a le s >

    1

    [email protected]

    UC: Scenario based requirements modeling

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

    1

    [email protected]

    Use Case 1

    Specifies the intended behavior (the what?) of asystem.

    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

    Used to:

    describe customer requirements (early analysis).

    Validate your architecture / verify your system.

    1

    [email protected]

    Use Case 2

    Each sequence (also called a scenario)represents the interaction of things outsidethe system (its actors) with the system itself(or parts of the system).

    Separate main vs. alternative flows

    Process loan

    Loan Officer

    ActorUse case

  • 8/4/2019 Aydoo 07 Usecase Modeling

    4/12

    1

    [email protected]

    Use Case Example

    Name: Capture deal

    Precond: Financial Officer is logged inMain 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

    Client

    Financial

    Officer

    Capture deal

    [email protected]

    Use cases: terms and concepts

    Unique namee.g.: Place order, Validate user

    Sequence of actions (event flows)- textual (informal, formal, semi formal)

    Main flow of events:The use case starts when thesystem prompts the Customerfor a PIN number.The Customercan now enter a pin number...

    Exceptional flow of events:If the Customerentersam invalid PIN number

    - interaction diagrams

    1

    [email protected]

    Actors

    Role that a human/hardware device/another system plays with respect to thesystem

    Actors carry out use cases- look for actors, then their use cases

    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)

    [email protected]

    Actors

    Actors can be specialized

    connected to use cases only by association

    association = communication relationship(both can send messages to, or receivemessages from the other one)

    Officer

    Loan Officer

    specializationrelationship

    [email protected]

    Use case description

    Generic, step-by-step written description ofa use cases event flow- Describe precondition (initial system state)

    - List sequence of steps

    Includes interactions with actor(s), anddescribes what objects are exchanged

    May contain extension points

    Clear, precise, short descriptions

    4

    [email protected]

    Organizing Use Cases: Generalization Relationship

    child use case inheritsbehavior and meaning ofthe parent use case

    child may add or override

    the parents behavior

    child may be substitutedany place the parentappears

    Validateclient

    Checkpassword

    Retinalscan

  • 8/4/2019 Aydoo 07 Usecase Modeling

    5/12

    [email protected]

    Organizing UC: Include Relationship

    Used to avoid describing the same flow of eventsseveral times, by putting the common behavior ina use case of its own

    Avoids copy & paste of parts of use casedescriptions

    Validateclient

    Place

    order

    Track

    order

    [email protected]

    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,

    [email protected]

    Organizing UC: Extend relationship

    Allows to model the part of a usecase the user may see as optional

    Allows to model conditionalsubflows

    Allows to insert subflows at acertain point, governed by actorinteraction

    extension points (in textual eventflows)

    (set priority)

    Place order

    Extensionpoints:

    Set priority

    Place rushorder

    [email protected]

    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

    [email protected]

    Using Extends relationship

    Capture the base use case if we later delete extension points,we still have to have a use caseachieving

    something!

    For every step ask- - what could go wrong?

    - - how might this work out differently?

    Plot every variation as an extension of theuse case

    [email protected]

    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

  • 8/4/2019 Aydoo 07 Usecase Modeling

    6/12

    1

    [email protected]

    Extends and Includes Relationships

    Extends

    IncludesFind Itemby Title

    Find Items

    by Actor

    Search Movie

    Database

    includes

    includesCustomer

    Dependency

    extends

    Stereotype

    Check In

    MovieAssess

    Late FeesClerk

    [email protected]

    A use case diagram

    Valuation

    Limit

    exceeded

    Analyze

    risks

    TraderPrice

    details

    Capture

    deal

    Sales person

    [email protected]

    When and how

    When:

    Requirements capture - first thing to do

    How:

    Use case: Every discrete thing yourcustomer wants to do with the system

    - give it a name

    - describe it shortly (some paragraphs)

    - add details later

    4

    [email protected]

    Recipe / Tasks to do

    Identify actors that interact with the system

    Organize actors

    Consider primary ways of interaction withactors

    Consider exceptional ways

    Organize behaviors as use cases, usinggeneralize/include/extend relationships

    Describe what actors require from system,not what goes on in the system!

    The EndUse Cases

    A Practical Example

    Compiled by Jesus Zavala

    [email protected]

  • 8/4/2019 Aydoo 07 Usecase Modeling

    7/12

    [email protected]

    Ski resort information system

    Users should be able to query weather and snow conditionforecasts for a date they enter.

    The system should allow to book single or double rooms at theresort hotel Skiers Luck online (with credit card).

    Visitors should be able to book one-day beginners courses onsnowboards.

    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 builtcourses with kids of same age, the customer has to enter thekids age.

    Canceling of course or room bookings are only possible up to10 days ahead.

    [email protected]

    First Trying

    [email protected]

    Errors you should prevent 1!

    >

    stereotype in actor

    associations

    4

    [email protected]

    Errors you should prevent 2!

    Associations

    between actors

    Unnamed

    associations

    between use

    cases

    41

    [email protected]

    Errors you should prevent 3!

    System

    no use

    case!

    Name

    relations!

    4

    [email protected]

    Errors you should prevent 4!

    Wrong

    understanding

    of the

    stereotype

  • 8/4/2019 Aydoo 07 Usecase Modeling

    8/12

    4

    [email protected]

    Errors you should prevent 5!

    Diagram moves main

    functionality outside the

    system

    44

    [email protected]

    Errors you should prevent 6!

    Data structures instead of

    functions as use cases, e.g.

    date, age, database

    relations not named

    4

    [email protected]

    Example Use Case Diagram

    Query

    weather&snowforecast

    Book room

    Book kidsSB course

    Visitor

    Cancelcourse

    Book SBcourse

    Cancel

    room

    Enterpersonal info

    (Enter kids age)

    4

    [email protected]

    Use Case 1

    Use Case: Query weather&snow forecast

    Precond: -

    Main flow:

    1. Visitor enters date

    2. Weather & snow forecast for local region isdisplayed for specified date

    4

    [email protected]

    Use Case 2

    Use Case: Book SB course

    Precond: -

    Main flow:1. Visitor enters date

    2. Include (Enter personal info)

    3. (Enter kids age)

    4. Store reservation

    5. Confirm reservation to Visitor

    Exceptional flow:If number of course participants for specified date > 8, then tell

    visitor so and let him choose another date

    4

    [email protected]

    Use Case 3

    Use Case: Book kids SB course

    Precond: SB course is for a kid

    Main flow:1. Enter kids age

    2. Store reservation

    3. 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 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.

  • 8/4/2019 Aydoo 07 Usecase Modeling

    9/12

    4

    [email protected]

    Literature Reference Management System

    Storage and retrieval of references, e.g.

    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 CaseDiagram (at leasttwo use cases)

    Describe usecases (at leastone)

    [email protected]

    Use Case Diagram: Lit Ref Mgmt Sys

    Addreference

    Removereference

    Search for

    reference

    User

    List

    references

    1

    [email protected]

    Event flow: List references

    Precondition: user has selected listreferences functionality.

    The system prompts the user to select thedevice: printer or file.

    The system prompts the user to select theprint order: by name or by title.

    The use case finishes with the systemprinting the list on the requested device.

    [email protected]

    Event flow: Add reference

    Precondition: user has selected add new referencefunctionality.

    The system prompts the user to select if he/she wantsto add a normal reference or a book.

    The system prompts the user to enter title, author, andpublisher of the reference(Add journal paper)(Except-1).

    The user is notified that the reference has beensuccessfully added.

    Except-1: The reference already exists. The user canre-enter the data or terminate the use case.

    [email protected]

    Use case: Add journal paper

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

    Add journal

    paperAdd reference

    Use Case Example

    ElevatorBy Jesus Zavala

    [email protected]

  • 8/4/2019 Aydoo 07 Usecase Modeling

    10/121

    [email protected]

    Elevator -- Use Case

    press an elevator button

    press a floor button

    User

    Elevator

    enter and exit through a door

    1 elevator, n

    floors

    [email protected]

    Example: Bank Account Manager

    Use case for withdrawal

    Use case for depositing

    Use case for balance query

    Small Test:

    Draw a Use Case Diagram(Organize use cases)

    Describe use cases

    [email protected]

    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/heraccount.

    The user should get a receipt for a transaction onrequest. 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 bedisplayed to the user.

    [email protected]

    Errors regarding arrows (connections)

    connection between actors and use cases haveno direction

    Connections between use cases are dotted( ) and should be labeled or

    :arrow points from use case describing thealternative event flow to the standard case

    :arrow points from calling use case to use casethat describes actions to include

    [email protected]

    Errors regarding relation graph & desc

    If use cases are connected then in thetextual description we have to mirror this:

    -

    - include (verify user)

    - - (print receipt)...

    [email protected]

    Errors regarding textual desc of use cases

    Preconditions not given

    No connection to graphical representation

    Different names in graphical and textual

    representation:user vs visitoruse case name different

    bank info vs user info

    But also: use case name appearing severaltime in diagram

  • 8/4/2019 Aydoo 07 Usecase Modeling

    11/121

    1

    [email protected]

    Other often occuring errors

    Flow charts instead of use casesremember: use case = sequence of actionsachieving a goalnot: action = use case

    Exceptional flow: not only exceptioncondition, but also actions if it occurs

    Exceptional flow: indicate in main flow atwhich point to check for this exception (ifnot obvious)!

    [email protected]

    Good solution 1

    User

    withdraw

    deposit

    check

    balanceVerify user

    withdraw withreceipt

    deposit with

    receipt

    (print receipt)

    (print receipt)

    [email protected]

    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 loweramount

    4

    [email protected]

    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)

    [email protected]

    Good solution 4

    Use case: check balance

    Precondition: User has selected balance

    option

    Main flow: Include (Verify user)

    Print balance

    [email protected]

    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

  • 8/4/2019 Aydoo 07 Usecase Modeling

    12/121

    [email protected]

    Good solution 6 (not required in test)

    Use case: withdraw with receipt

    Precondition: User has selected withdraw option andprint receipt option

    Use case: deposit with receipt

    Precondition: User has selected deposit option andprint receipt option

    ...

    [email protected]

    Acceptable solution 1

    User

    withdraw

    deposit

    checkbalance

    withdraw withreceipt

    deposit withreceipt

    (print receipt)

    (print receipt)

    [email protected]

    Acceptable solution 2

    Use case: withdraw

    Precondition: User is verified and hasselected withdraw option

    Similar for other use cases

    The End