Improving Use CasesHow to evaluate and upgrade use cases
Use cases shouldalways bereviewed with aneye towardimprovement
Guidelines fall into three main categories ¡ General ¡ Scenario style ¡ Scenario contentWell use the nomenclatureproposed by Camille Salinesi ofthe University of Paris
Lets start with the fivegeneral guidelines ¡ These deal with the use case as a whole
GG1: Identify every use caseby a goal statement¡ Structured as a predicate composed of a verb and complements
GG2: Use a template¡ "Use cases are not just composed of scenarios; employ the Use Case template that is given to you to characterize your Use Cases with all the Use case attributes"
GG3: Describeeach scenarioseparatelyA use case is always composedof several scenarios thatdescribe alternate ways to try toachieve the goal
GG4: Be consistent whenwriting scenarios¡ Write all scenarios in a consistent way in their ¡ Terminology ¡ Style ¡ Contents
GG5: Validateuse cases and tryto discover otherscenarios¡ Use a checklist with these and other guidelines¡ Then analyze them to discover other use cases and scenarios
The ten scenariostyle guidelinesThey deal with¡ Flows of actions (SG1 – SG6)¡ Initial and final states (SG7)¡ Terminology (SG8 – SG10)
SG1: Use present tense andactive voice¡ Scenarios are action clauses¡ They should be written in an explicit and complete way Wrong BetterThe personal identification number The ATM engine checks theis checked personal identification numberCheck the personal identification The ATM engine checks thenumber personal identification number
SG2: Avoid time, duration,location, manner and so on¡ Scenarios never include circumstances¡ These details tend to shape the solution prematurely Wrong BetterThe ATM engine checks the The ATM engine checks thepersonal identification number in personal identification numberless than thirty seconds
SG3: Only describe actionsthat should happen Wrong BetterThe ATM should not eject the cash Move the sentence to an alternateto the user scenario
¡ sadf SG4: Describe in chronological order Wrong Better The users account is updated The ATM checks the users after it has been properly account. checked The bank consortium updates the users account.
SG5: Duplicate sequencesonly if they involve differentobjects Wrong BetterThe ATM engine checks the validity The ATM engine checks the validitydate and serial number date The ATM engine checks the serial number … or … For each card attribute, the ATM engine checks the card attribute
SG6: Avoid else Wrong BetterIf the personal identification The ATM engine displays a promptnumber is correct, then the ATM for amount to the userdisplays a prompt for amount to the … and then move the carduser, otherwise the ATM ejects the ejection to an alternate scenariocard to the use
SG7: Dont describe statewithin a scenario¡ Start and finish states should have their own sections Wrong BetterThe user inserts a card into the ATM Create a use case calledbut the ATM is not ready to serve, so "Withdraw cash from a non-readyit ejects the card to the user ATM"
SG8: Be consistent; dont usesynonyms or homonyms¡ Synonym – Two words that have the same meaning ¡ eg. client and customer ¡ Pick one and stick to it¡ Homonym – One word with two meanings ¡ eg. user – Is this the employee or the customer? ¡ Use the different words Wrong BetterThe user enters his PIN The customer enters his PINThe user approves the transaction The employee approves theThe client removes the cash transaction The customer removes the cash
SG9: Avoid ambiguity¡ Avoid anaphoric references like he, she, or it¡ Anaphora – a word whose reference depends on context¡ Use nouns rather than pronouns Wrong BetterThe customer enters his PIN The customer enters his PINThe ATM engine checks to make The ATM engine validates the PINsure it is valid
SG10: Avoid making specificreferences to the scenariomodel¡ Dont refer to other scenarios unless you do so by name Wrong BetterThe customer enters his PIN What is a normal way? Go aheadThe ATM engine validates the PIN and describe in detail what thatCash is withdrawn in a normal way means … or … Cash is withdrawn according to UC117 Withdraw Cash
The nine content guidelines are what should be in the scenarios themselves
CG1: A scenario describesonly one flow¡ Each scenario is one possible way to reach the goal of the use case¡ If there are others, they are different scenarios in the same use case Wrong BetterIf the card is valid do ABC. If not, do Split into two scenariosXYZ.
CG2: Interactions have a name, two agents and one objectTry to use one of these templates:¡ <Agent> <’take’ Interaction > <Object> from <Agent>¡ <Agent> <’give’ Interaction > <Object> to <Agent>¡ <Agent> <’move’ Interaction > <Object> from <Agent> to <Agent>¡ <Agent> <’internal’ Interaction> <Object>¡ <Agent> <Interaction> <Agent> Wrong Better The user inserts his card The user inserts his card into the The PIN is checked ATM The ATM checks the PIN
CG3: A scenario describessequentially orderedinteractions¡ In other words, it tells a story¡ Dont know why this isnt #1 – the most basic description Wrong BetterThe user types a PIN into the ATM The user types a PIN into the ATMwhich checks it The ATM checks the card validity
CG4: Repetitions are okay¡ Use this formula:¡ Repeat <interactions> until <some condition> Wrong BetterThe user types a PIN in the ATM, the The user types a PIN in the ATM, andATM checks that the personal the ATM checks that the personalidentification number is correct. If identification number is correct untilthe personal identification number the personal identification numberis incorrect, the user types again is correct, or the user has typedthe personal identification number three incorrect personaland so on. identification numbers
CG5: Constraints are okay¡ As long as theyre expressed like this¡ If <some condition> then <interactions> Wrong BetterThe ATM checks the card validity The ATM checks the card validityIf the card is not valid, then the ATM If the card is valid, then the ATMejects the card to the user, else the displays a prompt for a personalATM displays a prompt for a identification number to the userpersonal identification number to … and put the else case inthe user another scenario
CG6: Interactions can beconcurrent¡ Word it like this:¡ <Interactions> meanwhile <another interaction> Wrong BetterThe ATM engine presents choices to The ATM engine presents choices tothe customer the customerThe ATM engine calculates the Meanwhile the ATM enginecustomers available balance calculates the customers available(Implies asynchronous activity) balance
CG7: Each scenario shouldhave start and final states¡ If a use case has multiple start or final states, it should be split into two use cases¡ … or reword the states Wrong BetterATM has paper (A machine can dispense cash even when it is out of paper) Customer has a card Customer has cash
CG8: All scenarios mustachieve a goal. Allexceptions must fail toachieve it Wrong BetterThe ATM checks the card validity. If The ATM checks the card validity.the card is not valid, the ATM If the card is not valid, the ATMswallows the card and the user calls swallows the cardthe ATM maintenance service
CG9: A scenario is at onlyone contextual level¡ Tougher to grasp¡ A scenario should address only one of: ¡ contextual – flow of services among agents ¡ functional – interactions with the system ¡ physical – interactions between systems¡ So you must know which level and make sure you stick to just one level Wrong Better1. Bank issues a card to a customer Split into two or three use cases2. Customer inserts card into ATM3. ATM contacts bank to validatecard
Conclusion¡ All scenarios should be reviewed in order to improve them¡ The rules discussed give guidelines on exactly how that can be done