The Practical Guide to Use Cases Learnusecasesviaprac-calexamples,-ps&templates
MichaelShrivathsan
Copyright©2012Accomp Copyright©2012Accompa,Inc.,SantaCla a,Inc.,SantaClara,California ra,California
www.accompa.com/use-case-book FirstEdition Allrightsreserved.Nopartofthisbookmaybereproducedinanyformorbyanyelectronicor Allrightsreserved.Nopartofthisbookmaybereproducedinanyform orbyanyelectronicor mechanicalmeans,includinginform mechanicalmeans,includinginformationstorageandretrievalsystem ationstorageandretrievalsystems,withoutpriorwritten s,withoutpriorwritten permissionfromAccompa,Inc.,exceptbyareviewerwh permissionfromAccompa,Inc.,exceptbyareviewerwhomayquoteabriefpassageas omayquoteabriefpassageas permittedunderSections107or108ofthe1976UnitedStatesCopyrightAct. Trademarkednamesappearinthisbook.Ratherthanuseatrademarksymbolwithevery occurrenceofaname,weusethenamessolelyinaneditorialfashionandtothebeneQitoft occurrenceofaname,weusethenamessolelyin aneditorialfashionandtothebeneQitoft he trademarkowner,withnointentionofinf trademarkowner,with nointentionofinfringement. ringement.
The Practical Guide to Use Cases
FormyGrandma,whotaughtme FormyGrandma,whotaughtmetoworkhard toworkhard anddreambig.
2
The Practical Guide to Use Cases
FormyGrandma,whotaughtme FormyGrandma,whotaughtmetoworkhard toworkhard anddreambig.
2
The Practical Guide to Use Cases
Table of Contents Preface ............................................................ ........................................................................................................................... .................................................................................. ...................4 1. Introduction ....................................................... ....................................................................................................................... ........................................................................ ........5 2. What’s in a Name? ....................................................... .................................................................................................................... .............................................................6 3. The Who ............................................................... ............................................................................................................................... ........................................................................ ........7
4. The Why ............................................................... ............................................................................................................................... ........................................................................ ........8
5. All the Jargon That’s Fit to Print! ................................................................ ..................................................................................... .....................10 6. How to Write a Use Case ............................................................ ...................................................................................................... ..........................................11 7. All the Jargon That’s Fit to Print – The Sequel .............................................................13 8.H 8.How owt to oWr Writ ite e“F “Ful ully ly-D -Dre ress ssed ed” ”Us Use eCa Case ses s(“ (“Na Nake ked” d”i is sso sooo oos sto tone nea age ge!) !) ...............14 9. Relationship Tips .............................................................. ................................................................................................................... .....................................................17
10. How to Write Use Cases for a Real-World Project ....................................................18 11. Templates and Tools ................................................................ .......................................................................................................... ..........................................22 12. Ten Do’s ......................................................... ......................................................................................................................... .......................................................................... ..........24 13. Frequently Asked Questions ............................................................ ............................................................................................ ................................26 14. Further Reading .............................................................. ................................................................................................................... .....................................................28 15. Glossary ......................................................... ......................................................................................................................... .......................................................................... ..........29 AboutAccompa-Softwar AboutAccompa-SoftwaretoManage etoManageUseCase UseCases s ............................................................31
3
The Practical Guide to Use Cases
Preface Whoisthisbookfor? Ifyouparticipateinsoftwaredevelopmentprojects,thisbookcanhelpyou.The mostcommonjobrolesthatthisbookistargetedatinclude: • • • •
BusinessAnalysts Project/ProgramManagers Programmers Peopleinotherrelatedroles
• • •
ProductManagers EngineeringManagers ATesters
Whatisthegoalofthisbook? Mygoalforthisbookistohelpyoulearnthe practical f undamentalsof“Use Cases”foruseinsoftwaredevelopmentprojects. Ifyouareabeginnertothetopicof“UseCases”–thisbookcanhelpyoulearnthe basicsofthistopicandbuildastrongfoundation.Ifyouareanexperiencedveteran –thisbookcanhelpyoutrainothersaboutusecases.
HowamIqualifiedtowritethisbook? Igotstartedwritingsoftwarerequirementsinthemid-1990s.SincethenI’vebeen writingrequirements,managingteamswhowritethem,and/ortrainingteamsto writebetterrequirements–includingusecases.I’veperformedtheserolesfor5 successfulhigh-techcompaniesinSiliconValley. Since2009,I’vebeentheVPofProductManagementfor Accompa–wemakethe popularcloud-basedrequirementsmanagementsoftware.Inthisrole,I’veworked withanumberofourcustomers(Fortune-500companiestogrowingstartups)to helpthemimplementusecasesintotheirrequirementsmanagementprocess. IstartedwritingthisbooktohelpAccompacustomers.Idecidedtoshareitwith everyoneasIrealizedmorepeoplecouldbeneQitfromit.
Howisthisbookorganized? WestartwithasimpledeQinitionandanexample.WethenuseaQictionalproject (onlinebookstore)toQleshoutusecases.Alongtheway,we’lldeQineandexplain variousconceptsandterms.Youcanreadthisbookovermultiplesessions. Thisbookdoesnotcovercomplextheories.Instead,itfocusesonhowusecasescan helpyouinreal-lifeprojects.Justtheessentials,ma’am!
4
The Practical Guide to Use Cases
1. Introduction Letusdiverightintoit.Whatexactlyisa“UseCase”anyhow? We’llstartwithasimpledeQinitionQirst.We’llthenreQineitafewtimesaswe progressthroughthebookandarriveatourQinaldeQinitioninalaterchapter.
“UseCase”Defini-on#1 Simplyput: A “Use Case” describes how a user reaches a specific goal.
Soundsverysimple-right?Well,notsofast!ThisisonlyapreliminarydeQinition, we’llmakeitmorecomplexsoon–Ipromise! We’lldeQinethetermsitalics(i.e.userand goal )laterinthisbook.Wewilleven deQineabettertermtouseinplaceofuser . Nowletustakealookatasampleusecase.
UseCaseExample#1 Throughoutthisbook,wewilluseaQictionalprojecttodemonstratethevarious conceptsaboutusecases.Thisprojectinvolvesbuildingan“OnlineBookstore”. Here‘sabasicexampleofausecaseforthisproject: Buyabook UserQindsabookhewantsandplacesanorder.Systemacceptstheorder,and sendsitforfulQillment. Asyoucanseefromthisexample,ausecasecanbeverysimple.Inthenextchapter, wewillclarifysometerminologymanypeopleQindconfusing.Thenwewilldive deeperintousecases. Beforewedothat,hereisafunexerciseforyou.
Exercises 1)
Writeabasicusecaseforyourproduct.Itdoesn’thavetobe“correct”-just writeitbasedontheexampleabove,youwillreviseitinlaterexercises.
5
The Practical Guide to Use Cases
2. What’s in a Name? UseCasesvs.Requirements Aquestionthatcomesupoftenis“Areusecasesrequirements?” Fortunately,theanswerisprettysimple.Andtheansweris:“Yes”! Usecasesareindeedrequirements–infact,theyrepresentaspeciQictypeof requirementcalled“ Functional”Requirement . Usecasesareactuallyoneofthebestwaysofdocumentingthefunctional requirements(sometimesreferredtoasBehavioralRequirements)ofasystem. Pleasenotethatinadditiontousecases,othertypesofrequirements(suchasNonfunctional,UI,etc)arealsoneededtofullydocumenttherequirementsofaproject. UseCasesvs.UserStories(Agile) IfyouarepartofateamthatfollowsAgiledevelopmentprocess(suchasScrum,XP, etc),you’reprobablyfamiliarwithUserStories. Youmightbewonderingwhattheheckisthedifferencebetween UseCasesand User Stories.Hey,afteralltheybothstartwiththeletters“Use”-right? OneofthebestexplanationsofthisdifferencecomesfromAndrewStellmaninthis blogpost .Here’saquicksummary(Irecommendthatyoureadtheentireblogpost whenyouhavetime)… UserStoriesdescribe“userneeds”–i.e.somethingthattheuserneedstodoinhis day-to-dayjob. Userstoriesdon’tcontainalotofdetails,theyareusuallyjust1or2short sentences.Theyarenotrequirementsbythemselves,butrather “conversationstarters”or“pointers”torequirements. •
UseCases,ontheotherhand,describethebehavioryou’llbuildintothesystemto meetuserneeds. Usecasesdescribeacompleteinteractionbetweenthesystemand user .Asa result,usecasesarerequirementsbythemselves. •
Insummary-UseCasesandUserStoriesaredifferentthings. Thatsaid- I’veseen someteamscreate“lightweight”usecases(suchastheexampleinchapter1ofthis book)andusetheminagileorhybrid-agileprojectsinplaceofepicuserstories.This isacontroversialapproachthough,andisgenerallynotrecommended. Nowthatwe’veclariQiedtheseterms,letuslookatwhoreadsandwritesusecases.
6
The Practical Guide to Use Cases
3. The Who Whoreadsusecases? Theprimaryreadersofusecasesare:Peoplewhoneedtounderstandwhatthe systembeingdevelopedmustdofunctionally.Thisincludesrolessuchas: Programmers Atesters Project/programmanagers,and Peopleinrelatedroles • • • •
Peoplewhoneedtoreview&approvethefunctionalityalsoreadusecases.This includesrolessuchas: Managers&Executives Customers Partners • • •
Whowritesusecases? Theprimarywritersofusecasesare:Peoplewhoneedtocommunicatetoothers whatthesystembeingdevelopedmustdofunctionally.Thisincludesrolessuchas: Productmanagers Businessanalysts Systemanalysts Project/programmanagers,and Peopleinrelatedroles • • • • •
Ok,nowthatwe’vedeQinedwhoreadsandwritesusecases-letusconsiderthe beneQitsofusingusecases.
Exercises 1) 2)
Writealistofpeopleinyourorganizationwhowillreadusecases. Writealistofpeopleinyourorganizationwhowillwritetheusecases.
7
The Practical Guide to Use Cases
4. The Why BenefitsofUseCases DocumentingfunctionalrequirementsviaUseCasesofferskeybeneQitstoall stakeholders-asusecasesarewrittenusingastandardtemplateandprocess: Programmers: Usecasesareeasiertoreadandunderstand.Nolong-winded,unstructured textthatcausesreaderstosufferMEGO(MyEyesGlazeOver). Users,Customers: Usecasesareeasytoreviewandprovidefeedback. Approvers&Executives: Usecasesmakeiteasiertoidentifywhatneedstoberemoved,andwhatis missing. •
•
•
Inaddition,usecasesalsoformanexcellentframeworkfornon-functional requirementsofthesystem–suchasperformance,scalability,userinterface,etc. LetusnowlookatasimpleexamplethatdemonstratesthesebeneQits.
Example:UnstructuredText&Structured UseCase BAD–UnstructuredText: Buyingabook Onlinebookstorehasawebsitethatcanbeaccessedovertheinternet.Theonline bookstorewebsiteoffersalistofbooks.Thislistcanbesearchedbyusers.The websiteprocessesandshipsbooktoanyonewhobuysabookfromtheonline bookstore.
GOOD–Structured UseCase: Buyabook 1. Uservisitsonlinebookstorewebsite. 2. Bookstorewebsitedisplaysasearchbox. 3. Usersearchesforthebookheislookingfor:Usingauthor,ISBNand/ortitle. 4. Bookstorewebsitedisplaysalistofmatchingbooks. 5. Userplacestheorderforoneormorebooks. 6. BookstorewebsiteprocessestheorderanddisplaysconQirmationtouser.
8
The Practical Guide to Use Cases
Asyoucansee,theusecasedescribesthefunctionalrequirementsofasysteminan easy-to-understand,structured textformat.Itismucheasiertoreadandunderstand comparedtotheunstructuredtext. Usecaseanswersquestionslikewho,whenand how muchmoreclearly. FYI:Inareal-worldproject,thisusecaseshouldbebrokeninto3or4separateuse cases.Wewilldojustthislateroninthisbook.I’vewrittenitasoneusecaseabove justtoquicklydemonstratetheadvantagesofusecasesoverabloboftext.
Nowwe’rereadytolookatamorecompletedeQinitionof“UseCase”.
Exercises 1) 2)
WritealistofbeneQitsyourorganizationcanenjoythroughusecases. ForeachbeneQit,identifywho(i.e.whichjobrole)willenjoythatbeneQit.
9
The Practical Guide to Use Cases
5. All the Jargon That’s Fit to Print! “UseCase”Defini-on#2 Here’sabetterdeQinition: A “Use Case” describes how an actor interacts with a system in order to achieve a goal.
LetusnowdeQinethetermsinitalicsabove,aswellasafewotherkeyterms frequentlyusedwhendiscussingusecases.
Defini-onsofCommonTerms(Part1) System Acomputer,electronicormechanicalsystem(oracombinationthereof)that iscapableofinteraction. SystemUnderDesign(SUD) TheSystemwe’redevelopingintheprojectforwhichwe’rewritingtheuse case. ExternalSystem ASystemthatisoutsideoftheSUD. Actor AhumanpersonoranExternalSystem. Goal Theobjectivethe Actorhas.Thisiswhythe ActorinteractswiththeSUDin themannerdescribedinaspeciQicusecase. Pre-condition ThestatethattheSUDwasinbeforetheinteractionsdescribedintheuse casestart. Post-condition ThestatethattheSUDwillendupinaftertheinteractionsdescribedinthe usecasearecompleted.
10
The Practical Guide to Use Cases
6. How to Write a Use Case RevisedExample Nowletusrevisetheusecasewewroteearliertomakeitmorethorough.
Buyabook,usingsearch SUD:OnlineBookstoreWebsite.Referredtoas“Bookstore”. Actor:Consumer
1. ConsumervisitsapageontheBookstoreusingawebbrowseronan internet-connectedcomputer. 2. Bookstoredisplaysthepage,whichincludesasearchbox. 3. Consumersearchesforthebookheislookingfor:Usingauthor,ISBNand/or title. 4. Bookstoredisplaysalistofmatchingbooks. 5. Consumeraddsoneormorebookstotheshoppingcart. 6. Consumerrepeatssteps3-5untilhehasaddedallthebookshewantsto purchasetotheshoppingcart. 7. Consumerinitiatescheckout. 8. Bookstorepromptsconsumertoenterorselectbilling&shippingaddresses. 9. Consumerentersaddresses. 10. Bookstorepromptsconsumertoenterorselectpaymentinformation. 11. Consumerenterspaymentinformationandplacesorder. 12. BookstoreprocessestheorderanddisplaysconQirmation&cross-sell informationtoconsumer.
5TipsforWri-ngaUseCase Hereare5tipsthatwillhelpyouinwritingusecases. 1. Startthetitleofeachusecasewithanactiveverb. o Noticehowinourexampleabove,westartedthetitlewiththeactive verb“Buy”. 2. Writeusingtheformatof: o ActordoesA o SystemdoesBinresponse o UserdoesC o SystemdoesDinresponse o … o Goalachieved
11
The Practical Guide to Use Cases
3. Startwritingtheusecase.Evenifitisroughandmissingkeyparts,start writingitQirst.Thenyoucanreviseittoimproveitandaddfurtherdetails. 4. Rememberourendgoalinwritingusecases:Wewanttodocument functionalrequirementsinaneasy-to-understandformat.Aslongaswe achievethisgoal,itistotallyQineifourusecasedoesnotfollowtherigid structure&rulessometimesprescribedby“usecasepurists”. 5. Ifausecasegetstoolong(saywellmorethan10-15steps),consider breakingitdownintotwoormoreusecases.Thiswillkeepourusecases easytoread. o Differentusecasescanbeconnectedtogetherusingthetipsin “LinkingUseCases”laterinthisbook. NowletusimproveourdeQinitionof“UseCase”further,andarriveataQinal deQinition.
Exercises 1)
Revisetheusecaseyouwrotein exercise1.1-usingtheexampleandtipsin thissection.Youshouldendwithausecasethatlookssimilartotherevised exampleinthissection.
12
The Practical Guide to Use Cases
7. All the Jargon That’s Fit to Print – The Sequel “UseCase”–FinalDefini-on Here’sourQinaldeQinitionof“usecase”: A “Use Case” describes the story of an actor interacting with the system under design (SUD) while achieving or failing to achieve a goal.
Thus,acompleteusecasedescribestheinteractionwhentheusersucceedsin achievingagoal,andwhenshefailstoachieveagoal.
Defini-onsofCommonTerms(Part2) PrimaryActor The Actor whoinitiatesaninteractionwiththeSUDtoachievetheGoal . Scenario Sequenceofinteractionsunderonecondition(suchas:UserQindsthebook he’slookingfor,UserisunabletoQindthebook,etc).Oneormorescenarios (makingupsuccess aswellas failureconditions)makeupausecase. MainSuccessScenario(MSS) TheScenarioinwhichnothinggoeswrong,andthePrimaryActor achieves theGoal . Extension AScenarioduringwhichsomethinggoeswrong,orsomethingdeviatesfrom theMSS . UseCaseID AuniqueID assignedtoausecase.WeshouldassignauniqueIDtoeachuse casewewrite–thismakesiteasiertocommunicateaboutalistofusecases.
13
The Practical Guide to Use Cases
8. How to Write “Fully-Dressed” Use Cases (“Naked” is sooo stone age!) Example–Revised NowletusrevisetheusecasewewroteearliertoincludeExtensions.Wewillalso maketheusecasemore“fullydressed”(i.e.morestructured). Name:
Buyabook,usingsearch
SUD:
OnlineBookstoreWebsite.Referredtoas“Bookstore”.
ID:
UC-1
PrimaryActor:
Consumer
Pre-condition:
Consumerisonacomputerconnectedtotheinternet.
MainSuccess Scenario:
1. ConsumervisitsapageontheBookstoreusingaweb browseronaninternet-connectedcomputer. 2. Bookstoredisplaysthepage,whichincludesasearch box. 3. Consumersearchesforthebookheislookingfor:Using author,ISBNand/ortitle. 4. Bookstoredisplaysalistofmatchingbooks. 5. Consumeraddsoneormorebookstotheshopping cart. 6. Consumerrepeatssteps3-5untilhehasaddedallthe bookshewantstopurchasetotheshoppingcart. 7. Consumerinitiatescheckout. 8. Bookstorepromptsconsumertoenterorselectbilling &shippingaddresses. 9. Consumerentersaddresses. 10. Bookstorepromptsconsumertoenterorselect paymentinformation. 11. Consumerenterspaymentinformationandplaces order. 12. Bookstoreprocessestheorderanddisplays conQirmation&cross-sellinformationtoconsumer.
14
The Practical Guide to Use Cases
Extensions: 4. (Extensionstosearch) A.Nomatchesfound i. Bookstoredoesnotfoundanymatches, andpromptstheconsumertorevisehis searchterms. ii. Consumerrevisessearchtermsand repeatsstep3ofMSS. B.Matchfound,butbookisoutofstock i. Bookstoreinformsconsumerthatthe bookisoutofstock,andisnotavailable forpurchase. ii. Consumeraddsthebooktohis“Alert List”,sothatBookstorecanemailhim onceitisavailable. 12. (Extensionstoorderprocessing) A.Paymentinformationisinvalid i. BookstoreQindsthepaymentinformation invalid,andpromptstheconsumertoreenterpaymentinformation. ii. Consumerre-enterspaymentinformation andrepeatsstep11ofMSS. Post-condition:
Consumerhassuccessfullyplacedtheorder.
Pleasenotethatinadditiontoaddingextensions,we’vealsoaddedmore “structureddata”tothisusecase.SpeciQically: ID Pre-condition Post-condition • • •
5TipsforWri-ngExtensions Hereare5tipsthatwillhelpyouwrite extensionsforausecase. 1. ForeverystepinMSSwherebehaviorcanbranchduetoa failurecondition– writedowntheconditionandthestepstohandleit. o Eachextensionisjustaveryshortusecasetohandlea failure condition. 2. Brainstormallpossible failureconditionswithyourteam.Thenprioritizethe extensionstodeterminewhichonesyouwillcoverinyourusecases. o Spendthetimetodothisstepwell. o Formostsoftwaresystems,documentingtheextensionscantakeas muchtime(ifnotmore)asdocumentingtheMSS.
15
The Practical Guide to Use Cases
Missingextensionsareoneofthetopcausesofpoorlydesigned products. o Thatsaid–youmuststrikeabalancebetweenavailabletimeand documentingeveryconceivableextension.Documentingevery conceivableextensionisoftennotrealistic-aseachstepinan extensioncanhaveitsownfailurecondition,andsoforth. 3. Eachextensionshouldendbyeither: o Re-mergingwithMSSsuccessfully,or o Primaryactorabandoningthegoal. 4. Writeeachextensionusingtheformatof: o NumbertheparentbulletoftheextensionusingthestepoftheMSS (suchas“4”,“12”intheaboveexample)wherebehaviorbranchesdue to failurecondition. o Giveeach failureconditionauniquenumber(suchas“4.A”,“4.B”and “12.A”intheaboveexample). o Titletheextensionusingabriefdescriptionof failurecondition.See thelineswithboldfont intheaboveexample. o Foreachextension,listnumberedstepsthatdescribehowSUDwill handlethecondition. o Theformatdescribedabovecanbeeasilyachievedwithsoftwaresuch asMicrosoftWordorAccompa. 5. Ifanextensiongetsverycomplicated,convertthatextensionintoanew, separateusecase. o Youcanlinkthenew(extension)usecasetotheparentusecase (MSS)usingthetipsin“LinkingUseCases”sectionbelow. o
Exercises 1) 2)
Revisetheusecaseyouwrotein exercise6.1–tomakeitfully-dressedasin theexamplethissection.YoucandownloadtheWordtemplatefromhere. Write 2-3 extensionsforyourrevisedusecaseusingtheexampleandtipsin thissection.
16
The Practical Guide to Use Cases
9. Relationship Tips LinkingUseCasesRela-onships Inreal-worldprojects,usecasesareoftenrelatedtooneanother.Itisvery beneQicial–andoftenabsolutelynecessary-tocreateanddocumentthese relationshipsaswewritealargenumberofusecases.Thiswillhelpusperform impactanalysisandtracingofourusecases. Thetwomostcommontypesofrelationshipsusedbetweenusecasesare“Extends” and“Includes”.Here’sadeQinitionoftheserelationships: Letusassumewehave3usecases: UC-1:Buyabook UC-5:Fixinvalidcreditcardinformation UC-14:Searchforabook • • •
Extends Wesay“UC-5extendsUC-1”whenUC-5describesan ExtensionofUC-1–i.e.a failureconditionforoneofthestepsintheMSSofUC-1. FYI:Thefollowingtwodescriptionsmeanthesamething: UC-5extendsUC-1 UC-1isextendedbyUC-5 • •
Includes Wesay“UC-1includesUC-14”whenUC-14describesastepofUC-1inmore detail. FYI:Thefollowingtwodescriptionsmeanthesamething: UC-1includesUC-14 UC-14isincludedbyUC-1 • •
WhileitispossibletocreateandmanagerelationshipsusingtoolssuchasMicrosoft Wordorwikis–mostteamsQinddedicatedrequirementsmanagementtoolssuchas Accompainvaluableforthispurpose.
Exercises 1) 2)
Identify1-2usecasesthat“extend”yourusecase.Youcansimplyconvertthe extensionsyouwroteinexercise8.2intoseparateusecases. Identify1-2usecasesthatare“includedby”yourusecase.
17
The Practical Guide to Use Cases
10. How to Write Use Cases for a Real- World Project Herearethestepsforwritingusecasesforareal-worldproject. Tip:Meetwithyourteamtoperformsteps1-4togetherasateam.Youcanthen workonstep5.1byyourself.Thenyoucanmeetwithyourteamagaintoreview MSS,andidentifyallfailureconditions(i.e.step5.2).
1. Createalistofactors(people,externalsystems). 2. Createalistofgoalsforeachactor-i.e.whateachactorwantstoachieve usingyoursystem. 3. NowyouhavetheQirstdraftofyourlistofusecases!Eachgoalbecomesa usecase. 4. Prioritizetheusecasesinyourlist.Priorityshouldbeassignedbasedonthe businessimportanceof: Theactor,and Thegoal. 5. Fleshouteachusecase: 5.1. DeQinethesuccessconditionforeachusecaseindetail–i.e.Main SuccessScenario. 5.2. Meetwithyourteamtoidentifyfailureconditionsforeachusecase. Createextensionstoaddressallmajorfailureconditions. 5.3. ItistotallyQinetocoversomeextensions,atQirst,onlyatahigh-level. Lateron,youcanQleshthemoutinmoredetail–andevenconvert themintoseparateusecases. 5.4. Incompleteusecasesresultfrequentlyfromforgettingfailure conditions,andcanleadtoasub-optimaluserexperience.Makesureto identifyallthekeyfailureconditions. § §
SampleListofUseCasesforanOnlineBookstore Herearesomeexamplesofausecaseyoumightwriteforaprojecttobuildan OnlineBookstore.Thisisjustapartiallist,togiveyouanidea–andfollowsthe samestepslistedabove. 1. Createalistofactorsforonlinebookstore: Actor
TypeofActor
Consumer
People
BookstoreManager
People
BookWarehouse
Externalsystem
18
The Practical Guide to Use Cases
3rdPartyBookList
Externalsystem
CreditCard Processor
Externalsystem
2. Createalistofgoalsforeachactor: Actor
Goal
Consumer
Browse books Searchforabook Buybook Placeorder Trackorder Cancelorder Writereview
BookstoreManager Trackorders Rundailyreports Providerefunds Moderatebookreviewsbyconsumers BookWarehouse
SendbookavailabilityinformationtoBookstore
3rdPartyBookList
Sendlistofbooksmeetingsearchcriteriato Bookstore SenddetailsofanindividualbooktoBookstore SendreviewsforanindividualbooktoBookstore
Credit Card rocessor
Send credit card validation results to Bookstore SenddailytransactionreporttoBookstore
3. Here’sthelistofusecases–createdusingthegoalslistedabove: ID
Use Case
Primary Actor
UC-1
Browse books
Consumer
UC-2
Search for a book
Consumer
UC-3
Buy book
Consumer
UC-4
Place order
Consumer
UC-5
Track order
Consumer
UC-6
Cancel order
Consumer
19
The Practical Guide to Use Cases
UC-7
Write review
Consumer
UC-8
Track orders
Bookstore Manager
UC-9
Run daily reports
Bookstore Manager
UC-10
Provide refunds
Bookstore Manager
UC-11
Moderatebookreviewsbyconsumers
Bookstore Manager
UC-12
Sendbookavailabilityinformationto Bookstore
BookWarehouse
UC-13
Sendlistofbooksmeetingsearchcriteriato Bookstore
3rdPartyBook List
UC-14
Senddetailsofanindividualbookto Bookstore
3rdPartyBook List
UC-15
Sendreviewsforanindividualbookto Bookstore
3rdPartyBook List
UC-16
Sendcreditcardvalidationresultsto Bookstore
CreditCard Processor
UC-17 SenddailytransactionreporttoBookstore
CreditCard Processor
4. Prioritizetheusecases: ID
Use Case
Primary Actor Priority of UseCase
UC-1
Browse books
Consumer
P1
UC-2
Search for a book
Consumer
P1
UC-3
Buy book
Consumer
P1
UC-4
Place order
Consumer
P1
UC-5
Track order
Consumer
P1
UC-6
Cancel order
Consumer
P2
UC-7
Write review
Consumer
P2
UC-8
Track orders
Bookstore Manager
P1
UC-9
Run daily reports
Bookstore Manager
P1
20
The Practical Guide to Use Cases
UC-10
Provide refunds
Bookstore Manager
P1
UC-11
Moderatebookreviewsby consumers
Bookstore Manager
P2
UC-12
Sendbookavailability informationtoBookstore
Book Warehouse
P1
UC-13
Sendlistofbooksmeetingsearch 3rdPartyBook criteriatoBookstore List
P1
UC-14
Senddetailsofanindividualbook 3rdPartyBook toBookstore List
P1
UC-15
Sendreviewsforanindividual booktoBookstore
3rdPartyBook List
P2
UC-16
Sendcreditcardvalidation resultstoBookstore
CreditCard Processor
P1
UC-17
Senddailytransactionreportto Bookstore
CreditCard Processor
P1
5. Fleshout eachusecase: Wewillleavethissectionasan“Exerciseforthereader”.Herearesometips: a. TakeeachusecaseinthetableaboveandQleshitoutasadetaileduse case.Includeasmuchdetailasnecessaryforyourorganizationtoact upontheseusecases–butnomore. b. Identify&documentextensionsforeachstepofeachusecase. c. Use includes&extends relationshipstolinkusecasestogether. Examplesfromthetableabove: i. UC-3 includesUC-1 ii. UC-3 includesUC-2 iii. UC-3 includesUC-4
Exercises 1)
Spend30-60minutestorecreatesteps1-4inthissectionforaspeciQic moduleofyourproduct/project.Youmaynotbeabletodothis comprehensivelyin30-60minutes–butyoushouldbeabletogetagood feel.
21
The Practical Guide to Use Cases
11. Templates and Tools UseCaseTemplate YoucandownloadMicrosoftWordtemplateforausecasefromthefollowinglink: DownloadUseCaseTemplate–MicrosoftWord YoucanchoosetouseonlysomeoftheQieldsinthetemplate–dependingonwhat worksbestforyourteam.Toparaphrasethefamousexpertonusecases,Albert Einstein:“Keepyourusecasetemplateassimpleaspossible,butnosimpler”!;)
So[wareToolstoManageUseCases Therearethreecategoriesofsoftwaretoolsthatarecommonlyusedtomanageuse cases.Letustakealookatthemandtheirpros/cons. 1. DesktopOficeSuite ManyteamsuseMicrosoftWord,Excelandsimilartoolstocreateandmanage theirusecases. Pros:Thesetoolsarewidelyavailableandeveryoneknowshowtousethem. Cons:Itishardertocapturestructureddata,createrelationships,andmanage usecasesforlargerprojects. 2. OnlineCollaborationTools Withthegrowingpopularityofwikisandonlinecollaborationtools(suchas GoogleDocs),teamsatmanycompaniesareadaptingsuchtoolstodocument theirusecases. Pros:Thesetoolsareeasytouse,andenableonlinecollaborationinreal-time. Cons:Itishardertocapturestructureddata,createrelationships,andmanage usecasesforlargerprojects. 3. DedicatedRequirementsManagementTools Whenteamsgrowoutoftoolssuchastheoneslistedabove,theystartusing dedicatedrequirementsmanagementtoolslikeAccompa. Pros:Thesetoolsmakeitmucheasiertocapturestructureddata,create relationships,andmanageusecasesforlargerprojects.Web-basedtoolsalso enablereal-timecollaborationovertheweb.
22
The Practical Guide to Use Cases
Cons:Thesearemoreexpensivethanthetoolslistedabove,andthereisa learningcurveforuserstolearnandusethem.
23
The Practical Guide to Use Cases
12. Ten Do’s Hereare10bestpracticestofollowwhenyouwriteusecases. 1. Keepthereaderinmind Alwaysrememberwhyyouarewritingtheusecases–i.e.tocommunicate information(aboutfunctionalrequirements)toyourreaders. Writingclear,easytounderstandusecasesisourgoal–farmoreimportant thanrigidlyadheringtoanyrules. 2. Identifyallactors Alwaysstartbyidentifyingalltheactors.DoingagoodjobonthisistheQirst stepinensuringyoudon’tmissanyimportantfunctionalrequirements. 3. Prioritizeusecases Alwaysprioritizeyourusecases.Ideally,youshouldprioritizethembasedon theirbusinessimportance. 4. Startwiththe“Satelliteview” OnlinemapssuchasGoogleMapshavea“satelliteview”and“streetview”.The “satelliteview”providesyouabroadviewofanarea-andasyoudrilldown deeper,yougettothe“streetview”. Whenyoustartwritingusecasesforaproject,alwaysstartwith“satelliteview” –i.e.withafocusonbreadth,notdepth.Thiswillgetyougoingquickly,and helpyouavoidgettingmiredindetailsattheoutset. Asyouprogress,youcanfocusmoreandmoreondepth–i.e.deQiningthe detailsforeachusecase.Thestepsoutlinedinchapter10willhelpyoudothis. 5. Useactivevoice I’venoticedthatmanypeople(includingme)haveatendencytowritein passivevoiceorfromtheperspectiveofthesystem. Thisresultsinstepssuchas“CreditcardisveriQied”–whichdoesn’tclearly deQinewhoperformedthestep.Alwayswriteinactivevoice–forexample: “CreditcardprocessingsystemveriQiesthecreditcard”. Tip:Starteachsentencewiththenameofanactor–thiswillhelpensurean activevoice.
24
The Practical Guide to Use Cases
6. Deinepre-conditions AlwaysdeQinepre-conditionsofeachusecase.Thishelpsthereaderunderstand thecontextoftheusecase.Evenwhenthecontextiscrystalcleartothewriter, readersareoftenconfused. 7. Deinepost-conditions AlwaysdeQinepost-conditionsofeachusecase.Thisnotonlyhelpsthereaders understandtheusecasebetter–italsoservesasa“contract”betweenthe projectteammembers. 8. Deinefailureconditions Studiesbymanyorganizations(suchasTheStandishGroup)havefound “Missedrequirements”tobeatopcauseofprojectfailures. Missedrequirementsoftenresultfromnotfullyaddressingfailureconditions. WorkwithyourteamtoidentifyallkeyfailureconditionsanddeQinethe behaviorclearly.Formostprojects,creatingusecasestoaddressfailure conditionswilltakeasmuchtimeasMSS–andoftenmuchlonger. Well-designedproducts,suchasthosefromApple,handlefailureconditionsina veryuser-friendlyfashion. 9. Writetextualusecases(Say“No”tostickigures,akaUMLdiagrams) Sometimesyoumayhearpeoplereferto“UMLDiagrams”asusecases–these arediagramscomposedofstickQigures,ellipsesandassortedother hieroglyphics(seethisblogpost foradiscussiononthistopic). Manyreadersofusecases-suchasendusers,engineers&businessexecutives- don’tknowhowtoreadUMLdiagrams.Thereisareasonwhyhumansevolved fromhieroglyphicstoalphabettext.Textiseasiertowrite&understand! Doallyourreadersafavor,andwritetextbasedusecases,inplainEnglish. WhenitcomestoUMLdiagrams,justsay“No”.Ifyou’renotconvincedyet, pleaserereadtip#1inthischapter. 10. Keepeachusecaseshort Writeshortusecases,nomorethan10-15stepsatthemost.Ifausecasegets longerthanthis,breakitupintomultipleusecases–andcreaterelationships (seechapter9)totiethemtogether. Usecaseslongerthan15stepsarehardertoread-andcausethosewhoread ourusecasestosuffertheafore-mentionedMEGO(MyEyesGlazeOver)effect!
25
The Practical Guide to Use Cases
13. Frequently Asked Questions 1. Areusecasesconsideredrequirements? Yes,usecasesareindeedrequirements.TheyareaspeciQictypeofrequirement– referredtoas“FunctionalRequirements”. So,usecasesareusedtodocumentsome,butnotall,oftherequirementsfora softwareproject. 2. Canusecasesbeusedinagileprojects? RequirementsforanAgileprojectareusuallydocumentedviaUserStories. Pleaseseechapter2ofthisbookforadiscussionofUseCasesvs.UserStories. 3. Howdoyouwriteandmanagelargevolumesofusecases? Pleaseseechapter10ofthisbookfora5-stepprocesstowriteandmanagelarge volumesofusecases. RequirementsmanagementsoftwaresuchasAccompacanbeveryhelpfulin doingthisaswell. 4. Whatroledo“UMLDiagrams”playinusecases? Ifyou’renotfamiliarwithUMLdiagrams(luckyyou!)–theyarediagrams consistingofstickQiguresandellipses,usedbysometodocumentusecases. AlistairCockburnwondersinhispopularbook“WritingEffectiveUseCases”: “Forreasonsthatremainamysterytome,manypeoplehavefocusedonthe stickQiguresandellipsesinusecasewriting…andhaveneglectedtonotice thatusecasesarefundamentallyatextform…” IagreewithAlistair.Ibelievethebestwaytowriteusecasesisusingtextual formatdescribedinthisbook. Justsay“No”toUMLdiagrams–theyareveryhardtounderstandformost peoplewhoreadtheusecaseswewrite. 5. Shouldusecasescontainanyinformationaboutuserinterface(UI)? Usecasespuristswilltellyouthatusecasesshouldnot containanyinformation aboutuserinterfaceatall. Well,I’mnotapuristwhenitcomestousecases(orprettymuchanythingelse!). IthinkitistotallyokaytoincludesomeinformationaboutUIinyourusecases. Ultimately,itdependsonwhatmakesthemostsenseforyourprojectteam. Thatsaid,pleaserememberthatourprimarygoalinwritingusecasesisto
26
The Practical Guide to Use Cases
documentthefunctionalrequirements–notUI. 6. Howdousecasesitintotheoverallrequirementsprocessforaproject? Increatingandmanagingrequirementsforaproject–3typesofartifactsare usuallycreatedandmanaged. a. Features High-levelfunctionalitythatasystemmustprovidetohelptheuser achieveanobjective. b. UseCases The functional requirementsneededtoimplementthefeature. c. Requirements Thenon-functionalrequirements(suchasperformance,security,UI design,scalability,etc)neededtoimplementthefeature. Pleaseseethisblogpost foramoredetaileddiscussionofofhowfeatures,use casesandrequirementsQittogether.Youmayalsowanttoreadthebook “SoftwareRequirements”byKarlWiegers(seelinkinthe“FurtherReading” chapterofthisbook)foranevenmoredetailedlookatthis. Inaddition,usecasesareusedasfollows: a. UIdesignteamscreatetheirUIdesignspeciQicationsbasedontheuse cases b. Developmentteamsbreakdowntheusecasestocreateworktasksfor developers c. Ateamscreatetestcases(forfunctionaltesting)basedontheusecases
27
The Practical Guide to Use Cases
14. Further Reading I’venowsharedwithyouasummarizedversionofwhatI’velearnedaboutusecases throughmanyyearsofhands-onexperience,andreadingsomegreatbooks.Ihopeit helpsyouintheonlywaythatcounts–todoyourjobbetterandbuildsuccessful products. TherearemanyintheindustrywhoknowwaymoreaboutusecasesthanIdo.My reasonforwritingthisbookisthattheydon’tseemtohavewrittenashortbookthat helpspeoplequicklylearnandbeneQitfromusecases. However,someofthemhavewrittengreatbooksonthesubject–I’velistedthem below.Iencourageyoutobuyandreadeveryoneofthem. 1. WritingEffectiveUseCases-AlistairCockburn Anindispensablebookthatwillhelpyoulearnandmasterusecases.Inaddition tothisbook,Alistairhascontributedimmenselytothesubjectofusecases. 2. SoftwareRequirements-KarlWiegers ThisisagreatbookbyKarlonmanagingrequirements.Thiscoversthetopicof requirementsmanagementthoroughly,includingusecases. 3. MasteringtheRequirementsProcess-SuzanneandJamesRobertson Anexcellentbookthatcoverstherequirementsprocessend-to-end,includinga verygoodtopiconusecases. 4. AppliedSoftwareProjectManagement -AndrewStellman,JenniferGreene Thisbookcoversmanytopicsonsoftwareprojectmanagement.Itisagoodto readtounderstandhowusecasesQitintooverallprojectmanagement.
28
The Practical Guide to Use Cases
15. Glossary Actor AhumanpersonoranExternalSystem. Extends Atypeofrelationshipusedtolinktogetherusecasesforaproject.Theother typeofrelationshipis“Includes”. Extension AScenarioduringwhichsomethinggoeswrong,orsomethingdeviatesfrom theMSS . ExternalSystem ASystemthatisoutsideoftheSUD. Goal Theobjectivethe Actorhas.Thisiswhythe Actor interactswiththeSUDin themannerdescribedinaspeciQicusecase. Includes Atypeofrelationshipusedtolinktogetherusecasesforaproject.Theother typeofrelationshipis“Extends”. MainSuccessScenario(MSS) TheScenarioinwhichnothinggoeswrong,andthePrimaryActor achieves theGoal . Post-condition ThestatethattheSUDwillendupinaftertheinteractionsdescribedinthe usecasearecompleted. Pre-condition ThestatethattheSUDwasinbeforetheinteractionsdescribedintheuse casestart. PrimaryActor The Actor whoinitiatesaninteractionwiththeSUDtoachievetheGoal . Relationship Usedtolinktogetherusecasesforaproject.Twotypesofrelationshipsare mostoftenused:Extends,Includes.
29
The Practical Guide to Use Cases
Scenario Sequenceofinteractionsunderonecondition(suchas:UserQindsthebook he’slookingfor,UserisunabletoQindthebook,etc.).Oneormorescenarios (makingupsuccess aswellas failureconditions)makeupausecase. System Acomputer,electronicormechanicalsystem(oracombinationthereof)that iscapableofinteraction. SystemUnderDesign(SUD) TheSystemwe’redevelopingintheprojectforwhichwe’rewritingtheuse case. UseCaseID AuniqueIDassignedtoausecase.WeshouldassignauniqueIDtoeachuse casewewrite–thismakesiteasiertocommunicateaboutalistofusecases.
30