CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza...

Preview:

Citation preview

CornellUniversity ComputingandInformationScience

CS5150SoftwareEngineering7.ScenariosandUseCases

WilliamY.Arms

Scenarios

Scenario Ascenarioisascenethatillustratessomeinteractionwithaproposedsystem.

Ascenarioisatoolusedduringrequirementsanalysistodescribeaspecificuseofaproposedsystem.Scenarioscapturethesystem,asviewedfromtheoutside,e.g.,byauser,usingspecificexamples.

Noteonterminology Someauthorsrestricttheword"scenario"torefertoauser'stotalinteractionwiththesystem.

Otherauthorsusetheword"scenario"torefertopartsoftheinteraction. Inthiscourse,thetermisusedwithbothmeanings.

DescribingaScenario

3

Someorganizationshavecomplexdocumentationstandardsfordescribingascenario.Attheveryleast,thedescriptionshouldinclude:•Astatementofthepurposeofthescenario•Theindividualuserortransactionthatisbeingfollowedthroughthescenario

•Assumptionsaboutequipmentorsoftware•Thestepsofthescenario

DevelopingaScenariowithaClient

Exampleofhowtodevelopascenariowithaclient Therequirementsarebeingdevelopedforasystemthatwillenableuniversitystudentstotakeexamsonlinefromtheirownroomsusingawebbrowser.

Createascenarioforhowatypicalstudentinteractswiththesystem. Inthenextfewslides,thequestionsinbluearetypicalofthe questionstoasktheclientwhiledevelopingthescenario.

DevelopingaScenariowithaClient:aTypicalStudent

Purpose:ScenariothatdescribestheuseofanonlineExamsystembyarepresentativestudent

Individual:[Whoisatypicalstudent?]StudentA,senioratCornell,majorincomputerscience.[Wherecanthestudentbelocated?Dootheruniversitiesdiffer?]

Equipment:Anycomputerwithasupportedbrowser.[Istherealistofsupportedbrowsers?Arethereanynetworkrestrictions?]

Scenario: 1. StudentAauthenticates.[HowdoesaCornellstudentauthenticate?] 2. StudentAstartsbrowserandtypesURLofExamsystem.[HowdoesthestudentknowtheURL?]

3. Examsystemdisplayslistofoptions.[Isthelisttailoredtotheindividualuser?]

DevelopingaScenariowithaClient(continued)

4. StudentAselectsCS1234Exam1. 5. Alistofquestionsisdisplayed,eachmarkedtoindicatewhether

completedornot.[Canthequestionsbeansweredinanyorder?] 6. StudentAselectsaquestionandchooseswhethertosubmitanew

answeroreditapreviousanswer.[Isitalwayspossibletoeditapreviousanswer?Arethereotheroptions?]

7. [Whattypesofquestionarethere:text,multiplechoice,etc.?]Thefirstquestionrequiresawrittenanswer.StudentAissubmittinganewanswer.Thestudenthasachoicewhethertotypethesolutionintothebrowserortoattachaseparatefile.StudentAdecidestoattachafile.[Whattypesoffileareaccepted?]

DevelopingaScenariowithaClient(continued)

8.Forthesecondquestion,thestudentchoosestoeditapreviousanswer.StudentAchoosestodeleteasolutionpreviouslytypedintothebrowser,andtoreplaceitwithanattachedfile.[Canthestudenteditapreviousanswer,ormustitalwaysbereplacedwithanewanswer?]

9.Asanalternativetocompletingtheentireexaminasinglesession,StudentAdecidestosavesthecompletedquestionstocontinuelater.[Isthisalwayspermitted?]

10..StudentAlogsoff.11.LaterStudentAlogin,finishestheexam,submitstheanswers,andlogsout.

[Isthisprocessanydifferentfromtheinitialworkonthisexam?]12.TheStudentAhasnowcompletedtheexam.Thestudentselectsanoption

thatsubmitstheexamtothegradingsystem.[Whatifthestudenthasnotattemptedeveryquestion?Isthegradernotified?]

DevelopingaScenariowithaClient(continued)

13. StudentAnowwishestochangeasolution.Thesystemdoesnotpermitchangesoncethesolutionhasbeensubmitted.[Canthestudentstillseethesolutions?]

14. LaterStudentAloginsintocheckthegrades.[Whenaregradesmadeavailable?Howdoesthestudentknow?]

15. StudentArequestsaregrade.[Whatarethepolicies?Whataretheprocedures?]

DevelopingaScenariowithaClient(continued)

9

• Developingascenariowithaclientclarifiesmanyfunctionalrequirementsthatmustbeagreedbeforeasystemcanbebuilt,e.g.,policies,procedures,etc.

• Thescenariowilloftenclarifytherequirementsfortheuserinterface,butthedesignoftheuserinterfaceshouldnotbepartofthescenario.

Althoughthisscenarioisquitesimple,manydetailshavebeenleftout.

ScenariosforAnalyzingSpecialRequirements

Scenariosareveryusefulforanalyzingspecialrequirements. Examples •Reversals.Inafinancialsystem,atransactioniscreditedtothewrongaccount.Whatsequenceofstepsareusedtoreversethetransaction?

•Errors.Amailordercompanyhasseveralcopiesofitsinventorydatabase.Whathappensiftheybecomeinconsistent?

•Malfeasance.Inavotingsystem,avoterhashousesintwocities.Whathappensifheattemptstovoteinbothofthem?

Scenariosforerrorrecovery Murphy'sLaw:"Ifanythingcangowrong,itwill".Createascenarioforeverythingthatcangowrongandhowthesystemisexpectedtohandleit.

ModelingScenariosasUseCases

Models Scenariosareusefulindiscussingaproposedsystemwithaclient,butrequirementsneedtobemademoreprecisebeforeasystemisfullyunderstood. Thisisthepurposeofrequirementsmodeling. Ausecaseprovidessuchamodel.

ThereisagooddiscussionofusecasesinWikipedia.TheapproachusedinthiscourseislesscomplexthantheWikipediaarticle.

TwoSimpleUseCases

12

BorrowBook

BookBorrower

RecordPressure

PressureSensor

ActorandUseCaseDiagram

•Anactorisauserofasystemina particularrole. Anactorcanbehumanoranexternal system.

•Ausecaseisaataskthatanactor needstoperformwiththehelpofthe system.

BorrowBook

BookBorrower

RecordPressure

PressureSensor

UseCasesandActors

•Actorisrole,notanindividual (e.g.,librariancanhavemanyroles) •Actormustbeabeneficiaryoftheusecase (e.g.,notlibrarianwhoprocessesbookwhenborrowed) Innamingactors,choosenamesthatdescribetherole,notgenericnames,suchas"user"or"client".

UseCasesforExamSystem

TakeExam

ExamTaker

CheckGrades

RequestRegradeThreeseparate

usecases

DescribingaUseCase

Someorganizationshavecomplexdocumentationstandardsfordescribingausecase.Attheveryleast,thedescriptionshouldinclude:•Thenameoftheusecase,whichshouldsummarizeitspurpose

•Theactororactors•Theflowofevents• Assumptionsaboutentryconditions

OutlineofTakeExamUseCase

NameofUseCase:TakeExam Actor(s):ExamTaker Flowofevents: 1.ExamTakerconnectstotheExamserver. 2.ExamservercheckswhetherExamTakerisalreadyauthenticatedandrunsauthenticationprocessifnecessary.

3.ExamTakerselectsaexamfromalistofoptions. 4.ExamTakerrepeatedlyselectsaquestionandeithertypesinasolution,attachesafilewithasolution,editsasolutionorattachesareplacementfile.

OutlineSpecificationofUseCase(continued)

Flowofevents(continued): 5.ExamTakereithersubmitscompletedexamorsavescurrentstate. 6.Whenacompletedexamissubmitted,ExamserverchecksthatallquestionshavebeenattemptedandeithersendsacknowledgementtoExamTaker,orsavescurrentstateandnotifiesExamTakerofincompletesubmission.

7.ExamTakerlogsout. Entryconditions: 1.ExamTakermusthaveauthenticationcredentials. 2.Computingrequirements:supportedbrowser.

UseCasesforExamSystem(continued)

SetExam

Instructor

Grade

Regrade

Notethatactorisarole.AnindividualcanbeanExamTakerononeoccasionandanInstructoratadifferenttime.

RelationshipsBetweenUseCases:<<includes>>

ExamTaker

Authenticate

TakeExam

<<includes>>

<<includes>>

CheckGrades

TheAuthenticateusecasemaybeusedinothercontexts

RelationshipsBetweenUseCases:<<extends>>

TakeExamExamTaker

ConnectionFails<<extends>>

<<includes>> isusedforusecasesthatareintheflowofeventsofthemainusecase.

<<extends>> isusedforexceptionalconditions,especiallythosethatcanoccuratanytime.

ScenariosandUseCasesintheDevelopmentCycle

Scenariosandusecasesarebothintuitive--easytodiscusswithclientsScenariosareatoolforrequirementsanalysis. •Theyareusefultovalidateusecasesandincheckingthedesignofasystem.

•Theycanbeusedastestcasesforacceptancetesting. Usecasesareatoolformodelingrequirements. •Asetofusecasescanprovideaframeworkfortherequirementsspecification.

•Usecasesarethebasisforsystemandprogramdesign,butareoftenhardtotranslateintoclassmodels.

UseCaseswithSeveralActors

ThisrestaurantexampleisbasedonausecasediagramfromWikipedia.

Waiter

Diner

Cashier

Chef

OrderFood

ServeFood

EatFood

PayforFood

OrderWine

CookFood

<<includes>>

UseCaseDiagrams

24

UsecasediagramsAusecasediagramshowstherelationshipsbetweenactorsandandtheirinteractionswithasystem.Itdoesnotshowthelogicofthoseinteractions.

AnOldExaminationQuestion

ThePizzaOrderingSystem ThePizzaOrderingSystemallowstheuserofawebbrowsertoorderpizzaforhomedelivery.Toplaceanorder,ashoppersearchestofinditemstopurchase,addsitemsoneatatimetoashoppingcart,andpossiblysearchesagainformoreitems. Whenallitemshavebeenchosen,theshopperprovidesadeliveryaddress.Ifnotpayingwithcash,theshopperalsoprovidescreditcardinformation. Thesystemhasanoptionforshopperstoregisterwiththepizzashop.Theycanthensavetheirnameandaddressinformation,sothattheydonothavetoenterthisinformationeverytimethattheyplaceanorder.

Developausecasediagram,forausecaseforplacinganorder,PlaceOrder.Theusecaseshouldshowarelationshiptotwopreviouslyspecifiedusecases,IdentifyCustomer,whichallowsausertoregisterandlogin,andPaybyCredit,whichmodelscreditcardpayments.

AnOldExaminationQuestion

Shopper

PlaceOrder

<<includes>>

IdentifyCustomer

PaybyCredit

<<includes>>

Correctsolution

Islinkisoptional

AnOldExaminationQuestion

WrongSolutionSearchMenu

PaybyCredit

<<includes>>

IdentifyCustomer<<includes>>

AddtoCart

Pay

Shopper

Recommended