cs 5150 software engineering 7. scenarios and use cases...the pizza ordering system the pizza...

27
Cornell University Computing and Information Science CS 5150 Software Engineering 7. Scenarios and Use Cases William Y. Arms

Upload: others

Post on 15-Dec-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

CornellUniversity ComputingandInformationScience

CS5150SoftwareEngineering7.ScenariosandUseCases

WilliamY.Arms

Page 2: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

Scenarios

Scenario Ascenarioisascenethatillustratessomeinteractionwithaproposedsystem.

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

Noteonterminology Someauthorsrestricttheword"scenario"torefertoauser'stotalinteractionwiththesystem.

Otherauthorsusetheword"scenario"torefertopartsoftheinteraction. Inthiscourse,thetermisusedwithbothmeanings.

Page 3: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

DescribingaScenario

3

Someorganizationshavecomplexdocumentationstandardsfordescribingascenario.Attheveryleast,thedescriptionshouldinclude:•Astatementofthepurposeofthescenario•Theindividualuserortransactionthatisbeingfollowedthroughthescenario

•Assumptionsaboutequipmentorsoftware•Thestepsofthescenario

Page 4: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

DevelopingaScenariowithaClient

Exampleofhowtodevelopascenariowithaclient Therequirementsarebeingdevelopedforasystemthatwillenableuniversitystudentstotakeexamsonlinefromtheirownroomsusingawebbrowser.

Createascenarioforhowatypicalstudentinteractswiththesystem. Inthenextfewslides,thequestionsinbluearetypicalofthe questionstoasktheclientwhiledevelopingthescenario.

Page 5: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

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?]

Page 6: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

DevelopingaScenariowithaClient(continued)

4. StudentAselectsCS1234Exam1. 5. Alistofquestionsisdisplayed,eachmarkedtoindicatewhether

completedornot.[Canthequestionsbeansweredinanyorder?] 6. StudentAselectsaquestionandchooseswhethertosubmitanew

answeroreditapreviousanswer.[Isitalwayspossibletoeditapreviousanswer?Arethereotheroptions?]

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

Page 7: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

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?]

Page 8: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

DevelopingaScenariowithaClient(continued)

13. StudentAnowwishestochangeasolution.Thesystemdoesnotpermitchangesoncethesolutionhasbeensubmitted.[Canthestudentstillseethesolutions?]

14. LaterStudentAloginsintocheckthegrades.[Whenaregradesmadeavailable?Howdoesthestudentknow?]

15. StudentArequestsaregrade.[Whatarethepolicies?Whataretheprocedures?]

Page 9: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

DevelopingaScenariowithaClient(continued)

9

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

• Thescenariowilloftenclarifytherequirementsfortheuserinterface,butthedesignoftheuserinterfaceshouldnotbepartofthescenario.

Althoughthisscenarioisquitesimple,manydetailshavebeenleftout.

Page 10: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

ScenariosforAnalyzingSpecialRequirements

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

•Errors.Amailordercompanyhasseveralcopiesofitsinventorydatabase.Whathappensiftheybecomeinconsistent?

•Malfeasance.Inavotingsystem,avoterhashousesintwocities.Whathappensifheattemptstovoteinbothofthem?

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

Page 11: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

ModelingScenariosasUseCases

Models Scenariosareusefulindiscussingaproposedsystemwithaclient,butrequirementsneedtobemademoreprecisebeforeasystemisfullyunderstood. Thisisthepurposeofrequirementsmodeling. Ausecaseprovidessuchamodel.

ThereisagooddiscussionofusecasesinWikipedia.TheapproachusedinthiscourseislesscomplexthantheWikipediaarticle.

Page 12: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

TwoSimpleUseCases

12

BorrowBook

BookBorrower

RecordPressure

PressureSensor

Page 13: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

ActorandUseCaseDiagram

•Anactorisauserofasystemina particularrole. Anactorcanbehumanoranexternal system.

•Ausecaseisaataskthatanactor needstoperformwiththehelpofthe system.

BorrowBook

BookBorrower

RecordPressure

PressureSensor

Page 14: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

UseCasesandActors

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

Page 15: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

UseCasesforExamSystem

TakeExam

ExamTaker

CheckGrades

RequestRegradeThreeseparate

usecases

Page 16: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

DescribingaUseCase

Someorganizationshavecomplexdocumentationstandardsfordescribingausecase.Attheveryleast,thedescriptionshouldinclude:•Thenameoftheusecase,whichshouldsummarizeitspurpose

•Theactororactors•Theflowofevents• Assumptionsaboutentryconditions

Page 17: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

OutlineofTakeExamUseCase

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

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

Page 18: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

OutlineSpecificationofUseCase(continued)

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

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

Page 19: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

UseCasesforExamSystem(continued)

SetExam

Instructor

Grade

Regrade

Notethatactorisarole.AnindividualcanbeanExamTakerononeoccasionandanInstructoratadifferenttime.

Page 20: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

RelationshipsBetweenUseCases:<<includes>>

ExamTaker

Authenticate

TakeExam

<<includes>>

<<includes>>

CheckGrades

TheAuthenticateusecasemaybeusedinothercontexts

Page 21: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

RelationshipsBetweenUseCases:<<extends>>

TakeExamExamTaker

ConnectionFails<<extends>>

<<includes>> isusedforusecasesthatareintheflowofeventsofthemainusecase.

<<extends>> isusedforexceptionalconditions,especiallythosethatcanoccuratanytime.

Page 22: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

ScenariosandUseCasesintheDevelopmentCycle

Scenariosandusecasesarebothintuitive--easytodiscusswithclientsScenariosareatoolforrequirementsanalysis. •Theyareusefultovalidateusecasesandincheckingthedesignofasystem.

•Theycanbeusedastestcasesforacceptancetesting. Usecasesareatoolformodelingrequirements. •Asetofusecasescanprovideaframeworkfortherequirementsspecification.

•Usecasesarethebasisforsystemandprogramdesign,butareoftenhardtotranslateintoclassmodels.

Page 23: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

UseCaseswithSeveralActors

ThisrestaurantexampleisbasedonausecasediagramfromWikipedia.

Waiter

Diner

Cashier

Chef

OrderFood

ServeFood

EatFood

PayforFood

OrderWine

CookFood

<<includes>>

Page 24: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

UseCaseDiagrams

24

UsecasediagramsAusecasediagramshowstherelationshipsbetweenactorsandandtheirinteractionswithasystem.Itdoesnotshowthelogicofthoseinteractions.

Page 25: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

AnOldExaminationQuestion

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

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

Page 26: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

AnOldExaminationQuestion

Shopper

PlaceOrder

<<includes>>

IdentifyCustomer

PaybyCredit

<<includes>>

Correctsolution

Islinkisoptional

Page 27: CS 5150 Software Engineering 7. Scenarios and Use Cases...The Pizza Ordering System The Pizza Ordering System allows the user of a web browser to order pizza for home delivery. To

AnOldExaminationQuestion

WrongSolutionSearchMenu

PaybyCredit

<<includes>>

IdentifyCustomer<<includes>>

AddtoCart

Pay

Shopper