6
From use cases From use cases to classes (in to classes (in UML) UML)

From use cases to classes (in UML). A use case for writing use cases Use case: writing a use case Actors: analyst, client(s) Client identifies and write

Embed Size (px)

Citation preview

Page 1: From use cases to classes (in UML). A use case for writing use cases Use case: writing a use case Actors: analyst, client(s) Client identifies and write

From use casesFrom use casesto classes (in UML)to classes (in UML)

Page 2: From use cases to classes (in UML). A use case for writing use cases Use case: writing a use case Actors: analyst, client(s) Client identifies and write

A use caseA use casefor writing use casesfor writing use cases

Use case: writing a use caseUse case: writing a use caseActors: analyst, client(s)Actors: analyst, client(s)

Client identifies and write down all the actors.Client identifies and write down all the actors.Analyst writes down all the actors.Analyst writes down all the actors.Client identifies the use cases, i.e., Client identifies the use cases, i.e., goalsgoals that actors can that actors can achieve step by step.achieve step by step.Analyst draws a use case Analyst draws a use case diagramdiagram documenting the documenting the relationships between the actors and use cases.relationships between the actors and use cases.Analyst describes Analyst describes mainmain scenario for a use case, step by step. scenario for a use case, step by step.Analyst describes any Analyst describes any alternativesalternatives to the main case. to the main case.Analyst reviews the use case with client to make sure it is Analyst reviews the use case with client to make sure it is understandable and correct. understandable and correct.

Alternative: Refine use caseAlternative: Refine use case7a.7a. If client may request changes then go to relevant step aboveIf client may request changes then go to relevant step above

Page 3: From use cases to classes (in UML). A use case for writing use cases Use case: writing a use case Actors: analyst, client(s) Client identifies and write

ExerciseExerciseI am the manager of a theatre.I am the manager of a theatre.I want to create an I want to create an automated movie ticket machineautomated movie ticket machine..You are analysts who need to describe You are analysts who need to describe what the customer wants as a set of use caseswhat the customer wants as a set of use casesSimplifying assumptions: Simplifying assumptions: One movie showing at a timeOne movie showing at a time Movie time is same every day, only one time, same priceMovie time is same every day, only one time, same price Only manager can change/add movieOnly manager can change/add movie Customer can only buy ticketsCustomer can only buy tickets

Who or what are the actors?Who or what are the actors?What are the use cases (goals of actors)?What are the use cases (goals of actors)?

Page 4: From use cases to classes (in UML). A use case for writing use cases Use case: writing a use case Actors: analyst, client(s) Client identifies and write

Use case diagramUse case diagramfor Movie Ticket Machinefor Movie Ticket Machine

Why are there three Actors?Why are there three Actors?

Why three use cases for Customer?Why three use cases for Customer?

Which use cases look easy to write?Which use cases look easy to write?

Page 5: From use cases to classes (in UML). A use case for writing use cases Use case: writing a use case Actors: analyst, client(s) Client identifies and write

Use cases for ManagerUse cases for ManagerUse case: Set titleUse case: Set titleActors: Manager, MachineActors: Manager, Machine1. Manager requests a change of movie title1. Manager requests a change of movie title2. Machine asks manager for new movie title2. Machine asks manager for new movie title3. Manager enters movie title3. Manager enters movie title

Use case: Set priceUse case: Set priceActors: Manager, MachineActors: Manager, Machine1. Manager requests a change of ticket price1. Manager requests a change of ticket price2. Machine asks manager for new price for movie title2. Machine asks manager for new price for movie title3. Manager enters ticket price3. Manager enters ticket priceAlternatives: Invalid priceAlternatives: Invalid priceIf manager enters price below $1 or greater than $10If manager enters price below $1 or greater than $103a. Machine asks manager to reenter price3a. Machine asks manager to reenter price

Use case: Set seatsUse case: Set seatsActors: Manager, MachineActors: Manager, Machine1. Manager requests a change in number of seats1. Manager requests a change in number of seats2. Machine asks manager for number of seats in theatre2. Machine asks manager for number of seats in theatre3. Manager enters number of seats3. Manager enters number of seatsAlternatives: Invalid number of seatsAlternatives: Invalid number of seatsIf manager enters number less than 20 or greater than 999If manager enters number less than 20 or greater than 9993a. Machine asks manager to reenter number of seats3a. Machine asks manager to reenter number of seats

Page 6: From use cases to classes (in UML). A use case for writing use cases Use case: writing a use case Actors: analyst, client(s) Client identifies and write

Use cases for CustomerUse cases for Customer

Use case: # of ticketsUse case: # of ticketsActors: Customer, MachineActors: Customer, Machine1. Customer enters number of tickets1. Customer enters number of tickets2. Machine displays total balance due2. Machine displays total balance dueAlternative: Customer wants zero ticketsAlternative: Customer wants zero ticketsAt step 1, customer enters zero ticketsAt step 1, customer enters zero tickets1a. Display thank you message1a. Display thank you message1b. Set balance to $0.01b. Set balance to $0.0

Use case: Return change to customerUse case: Return change to customerActors: Customer, MachineActors: Customer, Machine1. Customer requests change1. Customer requests change2. Machine dispenses money2. Machine dispenses money3. Machine updates customer balance3. Machine updates customer balance

Use case: Buy ticketsUse case: Buy ticketsActors: Customer, MachineActors: Customer, Machine1. Customer requests tickets1. Customer requests tickets2. Machine tells customer to put 2. Machine tells customer to put balance due in money slot balance due in money slot3. Customer enters money in money slot3. Customer enters money in money slot4. Machine updates customer balance4. Machine updates customer balance5. Customer requests tickets5. Customer requests tickets6. Machine prints tickets6. Machine prints tickets7. Machine updates number of seats7. Machine updates number of seatsAlternative: Insufficient seatsAlternative: Insufficient seatsAt step 1, if number of tickets requested At step 1, if number of tickets requested is less than available seats, is less than available seats, 1a. Display message and end use case1a. Display message and end use caseAlternative: Insufficient fundsAlternative: Insufficient fundsAt step 5, if money entered < total cost,At step 5, if money entered < total cost,5a. Display insufficient amount entered 5a. Display insufficient amount entered 5b. Go to step 35b. Go to step 3