IMSchach8thedChap12v7.docx
《IMSchach8thedChap12v7.docx》由会员分享,可在线阅读,更多相关《IMSchach8thedChap12v7.docx(26页珍藏版)》请在冰豆网上搜索。
IMSchach8thedChap12v7
Chapter12
ClassicalAnalysis
Inthischapter,threeapproachestospecificationarecompared:
formal,semiformal,andinformal.Ifeelthatstudentsshouldbeexposedtoasmanyformalmethodsaspossible.OnewaytointroducetheFSMmaterialtostudentswhohavehadnopriorexposuretoformalmachinesistodescribeamenu-basedproductwithwhichmoststudentsarefamiliar,suchasapopularword-processingpackageonaPC.Pointoutthateachmenucorrespondstoastate,andeachmenuchoicetoaninput.Oncestudentsappreciatethattheyhavebeendealingwithfinitestatemachinesforyears,Section12.7iseasytoteach.
StudentswhohavetakenanoperatingsystemscoursemaywellhavebeenexposedtoPetrinets.Also,thebasicconceptcanbeeasilyunderstoodbymostoftheclasswithoutmucheffortbytheinstructor.IbelievethatSection12.8shouldbecovered,ifonlytoensurethatstudentsareexposedtoPetrinets.However,notallstudentswillbeabletodoProblem12.17.
Ontheotherhand,IteachSections12.9and12.10toonlygraduatestudents.Furthermore,thereisonlyoneprobleminvolvingZattheendofthechapter.
problemsolutions
12.1:
Bothconstraintssuperficiallyappeartobepreciseandscientific,butneithercanbemeasuredortested.Specifically,
(i)Theterm“significantly”isimprecise—significantforwhom:
clientordeveloper?
Also,thisisareasonfordevelopingtheproduct,notaconstraint.
(ii)Theterm“reasonable”isimprecise—reasonableforwhom:
clientordeveloper?
12.2:
Anysuchomissions,contradictions,andambiguitieswillbecarriedoverintothedesignandimplementation.
12.3:
Ambiguities:
Isacloveoraheadofgarlictobeused?
Whatoperationsaretobeperformedthenightbefore?
Everything?
Whichjuiceistobestrained,orangeorlemon?
Whatistobefrozen,thelemonorjustthejuice?
Istheoniontobediced,orjusttheshallots?
Whichmixtureistobeblendedfor10minutes?
Does“blend”mean“mixbyhand”or“useanelectricblender?
”
Howarethelumpstoberemoved,withastrainerorablender?
Thelumpsinthemixturecouldbethemushrooms.
Twomixturesarespecified,thepockwesterisaddedtoonlyoneofthem:
which?
Howcanyoukilla“fresh”pockwester?
Theterms“simmer,”“bite-sized,”and“softtothetouch”areimprecise.
Wecanbroilforanytimefrom1microsecondto3minutes,59seconds.
WhatistobesprinkledwithParmesan—theservingplatter,orthepockwester?
Omissions:
Howlargeisa“largeonion”?
Whatsizecanoforangejuice?
Howlargealemon?
Whatkindofbreadforthecrumbs?
Howmuchflour?
Howmuchmilk?
Howlargearemedium-sizedshallots?
Howlargearemedium-sizedeggplants?
Whatsizepockwester?
Whatsizegarlic?
HowmuchParmesancheese?
Whatsizeeggs?
Thesugarisnotlistedintheingredients.
Norarethemushrooms.
Norarethefrobs.
Whatsizeplatteristobeused?
Contradictions:
Theingredientscallforfrozenorangejuice,therecipecallsforfresh.
Afterthelemonhasbeensqueezedthenightbefore,itisthensupposedtobesliced.
Wearetoldto“stirvigorously,”“slice,”and“inthemeantime”tocoat,dip,andsoon—itisimpossibletodoallthesethingsatonce.
Thefollowingitemsarecertainlyconfusing,buttheyarenotambiguities,omissions,orcontradictions:
Thelemonjuice,eggplant,andgarlicareneverused.
Grillinginaskilletisnotusuallyagoodidea.
Shakingupmushroomswetwithmilkinapaperbagisfraughtwithdifficulties.
Theinstructiontowhisktheeggsshouldprecedetheinstructiontoaddthemtoamixture.
Iftheblendingistobedonewithanelectricblender,10minutesseemstobetoolong.
Therecipecallsforfirstcoatingthemushroomsinflour,andthendippingtheminmilk;thismaybeunorthodox,butthensoismuchoftherestoftherecipe!
Twomixturesarespecified,thepockwesterisaddedtoonlyoneofthem;nothingismentionedregardingwhatistobedonewiththeotherone.
12.4:
Ifactualsalesforthecurrentmontharelessthanthetargetsalesforthecurrentmonth,checkwhetherthepercentagedifferencebetweentheactualsalesandthetargetsalesforthecurrentmonthis5percentormore.Ifso,checkwhethertherearesalesfiguresforthepreviousmonth.Ifso,checkwhetherthepercentagedifferencebetweentheactualsalesandtargetsalesforthecurrentmonthisgreaterthanorequaltohalfofthepercentagedifferencebetweentheactualsalesandtargetsalesforthepreviousmonth.Ifthisthirdconditionalsoholds,printareport.Otherwise,donothing.
12.5:
Foreachshop,theactualsalesforeachmontharecomparedwiththetargetsalesforthatmonth.
Theeffectivenessofagivenshopforagivenmonthisdefinedby
Theshortfallforagivenshopforagivenmonthisdefinedby
Ashopisdeemedtohaveachieveditsobjectiveforthecurrentmonthiftheshortfallforthecurrentmonthislessthanorequalto5%,oriftheshortfallforthecurrentmonthislessthanorequaltohalftheshortfallforthepreviousmonth;inthecaseofJanuary,theshortfallforthepreviousmonthisdeemedtobe0%.
Ifashophasnotachieveditsobjective,areportistobeprinted.
12.6:
Informalspecificationsareeasytouse,andareeasyfortheclienttounderstand.
12.7:
Informalspecificationsareimprecise.Theycanbeambiguous,contradictory,orincomplete.
12.8:
Thefollowingassumptionsaremade:
therearenoservicecharges,noATMwithdrawals.Theonlytransactionsthatareallowedarechecksanddeposits.Allchecksbearanumber.Theuserhasapileofcanceledchecks,andapileofdepositslips.
Figure12.1.Dataflowdiagramfordeterminingwhetherbankstatementiscorrect.
Sortthechecksincheck-numberorder.Foreachcheck,findanentryinthebankstatementthatmatchesthechecknumber.Ifnosuchentryisfound,thestatementisinerror.Otherwise,markthatentry,andverifythattheamountforthatentryisthesameasthatonthecheck.Iftheamountsdonotmatch,thestatementisinerror.
Sortthedepositslipsaccordingtodateofdeposit.Foreachdepositslip,findanentryinthestatementthatmatchesthedateofdepositandtheamountofthedeposit.Markthatentry.Ifnosuchentryisfound,thestatementisinerror.
Afterallchecksanddepositshavebeenprocessed,verifythatallitemsonthestatementhavebeenmarked.Ifnot,thestatementisinerror.
Addtheamountofalldepositstothebeginningbalance,andfromthatsumsubtractthetotalofallthechecks.Iftheresultofthatsubtractionisnotequaltotheendingbalancethenthestatementisinerror,otherwiseitiscorrect.
12.9:
SeeFigure12.1.
12.10:
Thisproductisconcernedwithbooks,borrowers,andlibrarians.Thelibraryhasacollectionofbooksthatborrowersmaycheckoutandsubsequentlyreturn.Eachbookhasauniquebooknumber.Affixedtoeachbookisalabelbearingthatnumberinbar-codeformat.
Eachborrowerhasauniqueborrowernumber.Eachborrowerhasacardbearingthatnumberinbar-codeformatthatisscannedwhentheborrowerchecksoutabook.BorrowersmaydetermineallthebooksbyaparticularauthorinthelibrarycollectionbygoingtoaterminalandenteringA=,allthebookswithaspecifictitlebyenteringT =,orallthebooksinaparticularsubjectareabyenteringS = .
LibrarianscheckoutabookbyenteringCataterminal,scanningtheborrowerbarcode,andscanningthebookbarcode.Ifthebookisnotbeingheldforanotherreader,itisissuedtotheborrower.Whenaborrowerreturnsabook,thelibrarianentersRataterminal,andscansthebookbarcode.Toaddanewbooktothecollection,thelibrarianenters+(plussign),thenumberofthenewbook,andotherbookdetails.Toremoveabookfromthecollection,thelibrarianenters–(minussign)andentersthebooknumber(bar-codeinputisinappropriate—thebookmayhavebeenstolen).AlibrariancanputaholdonabookforaborrowerbyenteringH=andscanningtheborrower’sbarcode.[Theneedfortheborrower’snumberwasintentionallyomittedfromtheproblemstatement;studentsshouldnotthoughtlesslyrewritetheproblemstatementinmoreformalterms,butactuallyconsidertheimplicationsofwhattheyarewriting!
]Abookmaynotbeheldifitisalreadybeingheldforanotherborrower.
12.11:
SeeFigure12.2.
12.12:
Step1.DrawDFD.Seepreviousproblem.
Figure12.2.Dataflowdiagramforlibrarycirculation.
Step2.Decidewhatsectionstocomputerize,andhow.ComputerizecompleteproductasshowninDFD,online.DFDdoesnotshowfunctionslikeissuingnewborrowerwithanIDnumberandcard,ormaintainingborrowerdetails.Thesefunctionswerenotincludedinthespecifications,anditisthereforeassumedthattheywillbeperformedmanually.
Step3.Detailsofdataflows.
book_ID
book_number
book_details
book_number
book_bibliographic_details
author
title
subject
other_details
borrower_ID
borrower_number
on_hold_data
borrower_numberifbookisonholdforanotherborrower,else0
Step4.Definelogicofprocesses.
addbook
Placebook_detailsinBOOK_DATA
checkoutbook
Readbook_ID,borrower_ID
Checkthatbookisnotbeingheldforanotherborrower
UpdateBOOK_DATAwithborrower_ID
holdbook
Readbook_ID,borrower_ID
Checkifbookisalreadyonhold
Ifnot,updateBOOK_DATAtoreflectborrower_ID
obtaincataloginformation
Readborrower’squery
SearchBOOK_DATA
Answerborrower’squery
removebook
Readbook_ID
Deletebook_detailsfromBOOK_DATA
returnbook
Readbook_number
UpdateBOOK_DATA