嵌入式拼图游戏-外文翻译_第1页
嵌入式拼图游戏-外文翻译_第2页
嵌入式拼图游戏-外文翻译_第3页
嵌入式拼图游戏-外文翻译_第4页
嵌入式拼图游戏-外文翻译_第5页
已阅读5页,还剩11页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

0外文原文CMainarticle:Cvariabletypesanddeclarations,ChasastaticweaktypingtypesystemthatsharessomesimilaritieswiththatofotherALGOLdescendantssuchasPascal.Therearebuilt-intypesforintegersofvarioussizes,bothsignedandunsigned,floating-pointnumbers,characters,andenumeratedtypes(enum).C99addedabooleandatatype.Therearealsoderivedtypesincludingarrays,pointers,records(struct),anduntaggedunions(union).Cisoftenusedinlow-levelsystemsprogrammingwhereescapesfromthetypesystemmaybenecessary.Thecompilerattemptstoensuretypecorrectnessofmostexpressions,buttheprogrammercanoverridethechecksinvariousways,eitherbyusingatypecasttoexplicitlyconvertavaluefromonetypetoanother,orbyusingpointersorunionstoreinterprettheunderlyingbitsofadataobjectinsomeotherway.SomefindCsdeclarationsyntaxunintuitive,particularlyforfunctionpointers.(Ritchiesideawastodeclareidentifiersincontextsresemblingtheiruse:declarationreflectsuse.)Csusualarithmeticconversionsallowforefficientcodetobegenerated,butcansometimesproduceunexpectedresults.Forexample,acomparisonofsignedandunsignedintegersofequalwidthrequiresaconversionofthesignedvaluetounsigned.Thiscangenerateunexpectedresultsifthesignedvalueisnegative.Csupportstheuseofpointers,atypeofreferencethatrecordstheaddressorlocationofanobjectorfunctioninmemory.Pointerscanbedereferencedtoaccessdatastoredattheaddresspointedto,ortoinvokeapointed-tofunction.Pointerscanbemanipulatedusingassignmentorpointerarithmetic.Therun-timerepresentationofapointervalueistypicallyarawmemoryaddress(perhapsaugmentedbyanoffset-within-wordfield),butsinceapointerstypeincludesthetypeofthething,pointedto,expressionsincludingpointerscanbetype-checkedatcompiletime.Pointerarithmeticisautomaticallyscaledbythesizeofthepointed-todatatype.PointersareusedformanydifferentpurposesinC.Textstringsarecommonlymanipulatedusingpointersintoarraysofcharacters.Dynamicmemoryallocation1isperformedusingpointers.Manydatatypes,suchastrees,arecommonlyimplementedasdynamicallyallocatedstructobjectslinkedtogetherusingpointers.Pointerstofunctionsareusefulforpassingfunctionsasargumentstohigher-orderfunctions(suchasqsortorbsearch)orascallbackstobeinvokedbyeventhandlers.Anullpointervalueexplicitlypointstonovalidlocation.Dereferencinganullpointervalueisundefined,oftenresultinginasegmentationfault.Nullpointervaluesareusefulforindicatingspecialcasessuchasnonextpointerinthefinalnodeofalinkedlist,orasanerrorindicationfromfunctionsreturningpointers.Inappropriatecontextsinsourcecode,suchasforassigningtoapointervariable,anullpointerconstantcanbewrittenas0,withorwithoutexplicitcastingtoapointertype,orastheNULLmacrodefinedbyseveralstandardheaders.Inconditionalcontexts,nullpointervaluesevaluatetofalse,whileallotherpointervaluesevaluatetotrue.Voidpointers(void*)pointtoobjectsofunspecifiedtype,andcanthereforebeusedasgenericdatapointers.Sincethesizeandtypeofthepointed-toobjectisnotknown,voidpointerscannotbedereferenced,norispointerarithmeticonthemallowed,althoughtheycaneasilybe(andinmanycontextsimplicitlyare)convertedtoandfromanyotherobjectpointertype.Carelessuseofpointersispotentiallydangerous.Becausetheyaretypicallyunchecked,apointervariablecanbemadetopointtoanyarbitrarylocation,whichcancauseundesirableeffects.Althoughproperlyusedpointerspointtosafeplaces,theycanbemadetopointtounsafeplacesbyusinginvalidpointerarithmetic;theobjectstheypointtomaybedeallocatedandreused(danglingpointers);theymaybeusedwithouthavingbeeninitialized(wildpointers);ortheymaybedirectlyassignedanunsafevalueusingacast,union,orthroughanothercorruptpointer.Ingeneral,Cispermissiveinallowingmanipulationofandconversionbetweenpointertypes,althoughcompilerstypicallyprovideoptionsforvariouslevelsofchecking.Someotherprogramminglanguagesaddresstheseproblemsbyusingmorerestrictivereferencetypes.2ArraytypesinCaretraditionallyofafixed,staticsizespecifiedatcompiletime.(ThemorerecentC99standardalsoallowsaformofvariable-lengtharrays.)However,itisalsopossibletoallocateablockofmemory(ofarbitrarysize)atrun-time,usingthestandardlibrarysmallocfunction,andtreatitasanarray.Csunificationofarraysandpointersmeansthatdeclaredarraysandthesedynamicallyallocatedsimulatedarraysarevirtuallyinterchangeable.Sincearraysarealwaysaccessed(ineffect)viapointers,arrayaccessesaretypicallynotcheckedagainsttheunderlyingarraysize,althoughsomecompilersmayprovideboundscheckingasanoption.31Arrayboundsviolationsarethereforepossibleandrathercommonincarelesslywrittencode,andcanleadtovariousrepercussions,includingillegalmemoryaccesses,corruptionofdata,bufferoverruns,andrun-timeexceptions.Ifboundscheckingisdesired,itmustbedonemanually.Cdoesnothaveaspecialprovisionfordeclaringmultidimensionalarrays,butratherreliesonrecursionwithinthetypesystemtodeclarearraysofarrays,whicheffectivelyaccomplishesthesamething.Theindexvaluesoftheresultingmultidimensionalarraycanbethoughtofasincreasinginrow-majororder.Multidimensionalarraysarecommonlyusedinnumericalalgorithms(mainlyfromappliedlinearalgebra)tostorematrices.ThestructureoftheCarrayiswellsuitedtothisparticulartask.However,sincearraysarepassedmerelyaspointers,theboundsofthearraymustbeknownfixedvaluesorelseexplicitlypassedtoanysubroutinethatrequiresthem,anddynamicallysizedarraysofarrayscannotbeaccessedusingdoubleindexing.(Aworkaroundforthisistoallocatethearraywithanadditionalrowvectorofpointerstothecolumns.)C99introducedvariable-lengtharrayswhichaddresssome,butnotall,oftheissueswithordinaryArray-pointerinterchangeability。Thesubscriptnotationxi(wherexdesignatesapointer)isasyntacticsugarfor*(x+i).32Takingadvantageofthecompilersknowledgeofthepointertype,theaddressthatx+ipointstoisnotthebaseaddress(pointed3tobyx)incrementedbyibytes,butratherisdefinedtobethebaseaddressincrementedbyimultipliedbythesizeofanelementthatxpointsto.Thus,xidesignatesthei+1thelementofthearray.Furthermore,inmostexpressioncontexts(anotableexceptionisasoperandofsizeof),thenameofanarrayisautomaticallyconvertedtoapointertothearraysfirstelement.Thisimpliesthatanarrayisnevercopiedasawholewhennamedasanargumenttoafunction,butratheronlytheaddressofitsfirstelementispassed.Therefore,althoughfunctioncallsinCusepass-by-valuesemantics,arraysareineffectpassedbyreference.Thesizeofanelementcanbedeterminedbyapplyingtheoperatorsizeoftoanydereferencedelementofx,asinn=sizeof*xorn=sizeofx0,andthenumberofelementsinadeclaredarrayAcanbedeterminedassizeofA/sizeofA0.Thelatteronlyappliestoarraynames:variablesdeclaredwithsubscripts(intA20).DuetothesemanticsofC,itisnotpossibletodeterminetheentiresizeofarraysthroughpointerstoarraysorthosecreatedbydynamicallocation(malloc);codesuchassizeofarr/sizeofarr0(wherearr=Adesignatesapointer)willnotworksincethecompilerassumesthesizeofthepointeritselfisbeingrequested.3334Sincearraynameargumentstosizeofarenotconvertedtopointers,theydonotexhibitsuchambiguity.However,arrayscreatedbydynamicallocationareinitializedtopointersratherthantruearrayvariables,sotheysufferfromthesamesizeofissuesasarraypointers.Thus,despitethisapparentequivalencebetweenarrayandpointervariables,thereisstilladistinctiontobemadebetweenthem.Eventhoughthenameofanarrayis,inmostexpressioncontexts,convertedintoapointer(toitsfirstelement),thispointerdoesnotitselfoccupyanystorage;thearraynameisnotanl-value,anditsaddressisaconstant,unlikeapointervariable.Consequently,whatanarraypointstocannotbechanged,anditisimpossibletoassignanewaddresstoanarrayname.Arraycontentsmaybecopied,however,byusingthememcpyfunction,orbyaccessingtheindividualelements.Puzzles4Manypuzzlesaretermedfullyinterlocking.Thismeansthatadjacentpiecesareconnectingsuchthatifyoumoveonepiecehorizontallyyoumoveall,preservingtheconnection.Sometimestheconnectionistightenoughtopickupasolvedpartholdingonepiece.Somefullyinterlockingpuzzleshavepiecesallofasimilarshape,withroundedtabsoutonoppositeends,withcorrespondingblankscutintotheinterveningsidestoreceivethetabsofadjacentpieces.Otherfullyinterlockingpuzzlesmayhavetabsandblanksvariouslyarrangedoneachpiece,buttheyusuallyhavefoursides,andthenumbersoftabsandblanksthusadduptofour.Theuniform-shapedfullyinterlockingpuzzles,sometimescalledJapaneseStyle,arethemostdifficult,becausethedifferencesinshapesbetweenpiecescanbeverysubtle.citationneededSomepuzzlesalsohavepieceswithnon-interlockingsidesthatareusuallyslightlycurvedincomplexcurves.Theseareactuallytheeasiestpuzzlestosolve,sincefewerotherpiecesarepotentialcandidatesformating.Mostjigsawpuzzlesaresquare,rectangular,orround,withedgepiecesthathaveonesidethatiseitherstraightorsmoothlycurvedtocreatethisshape,plusfourcornerpiecesifthepuzzleissquareorrectangular.Somejigsawpuzzleshaveedgepiecesthatarecutjustlikealltherestoftheinterlockingpieces,withnosmoothedge,tomakethemmorechallenging.Otherpuzzlesaredesignedsotheshapeofthewholepuzzleformsafigure,suchasananimal.Theedgepiecesmayvarymoreinthesecases.RequirementsPhaseThechancesofaproductbeingdevelopedontimeandwithinbudgetaresomewhatslimunlessthemembersofthesoftwaredevelopmentteamagreeonwhatthesoftwareproductwilldo.Thefirststepinachievingthisunanimityistoanalyzetheclientscurrentsituationaspreciselyaspossible.Forexample,itisinadequatetosay,“Theyneedacomputer-aideddesignsystembecausetheyclaimtheirmanualdesignsystem,thereislousy.“Unlessthedevelopmentteamknowsexactlywhatiswrongwiththecurrentmanualsystem,thereisahighprobabilitythataspectsofthenewcomputerizedsystemwill5beequally“lousy.“Similarly,ifapersonalcomputermanufactureriscontemplatingdevelopmentofanewoperatingsystem,thefirststepistoevaluatethefirmscurrentoperatingsystemandanalyzecarefullyexactlywhyitisunsatisfactory.Totakeanextremeexample,itisvitaltoknowwhethertheproblemexistsonlyinthemindofthesalesmanager,whoblamestheoperatingsystemforpoorsales,orwhetherusersoftheoperatingsystemarethoroughlydisenchantedwithitsfunctionalityandreliability.Onlyafteraclearpictureofthepresentsituationhasbeengainedcantheteamattempttoanswerthecriticalquestion,Whatmustthenewproductbeabletodo?Theprocessofansweringthisquestioniscarriedoutduringtherequirementsphase.Acommonlyheldmisconceptionisthat,duringtherequirementsphase,thedevelopersmustdeterminewhatsoftwaretheclientwants.Onthecontrary,therealobjectiveoftherequirementsphaseistodeterminewhatsoftwaretheclientneeds.Theproblemisthatmanyclientsdonotknowwhattheyneed.Furthermore,evenaclientwhohasagoodideaofwhatisneededmayhavedifficultyinaccuratelyconveyingtheseideastothedevelopers,becausemostclientsarelesscomputerliteratethanthemembersofthedevelopmentteam.Toelicittheclientsneeds,themembersoftherequirementsteammustbefamiliarwiththeapplicationdomain,thatis,thegeneralareainwhichtheproposedsoftwareproductistobeused.Forexample,itisnoteasytoaskmeaningfulquestionsofabankeroranursewithoutfirstacquiringsomefamiliaritywithbankingornursing.Therefore,oneoftheinitialtasksofeachmemberoftherequirementsanalysisteamistoacquirefamiliaritywiththeapplicationdomainunlessheorshealreadyhasexperienceinthatgeneralarea.Itisparticularlyimportanttousecorrectterminologywhencommunicatingwiththeclientandpotentialusersofthetargetsoftware.Afterall,itishardtobetakenseriouslybyapersonworkinginaspecificdomainunlesstheinterviewerusesthenomenclatureappropriateforthatdomain.Moreimportant,useofaninappropriatewordmayleadtoamisunderstanding,eventuallyresultinginafaultyproductbeingdelivered.Thesameproblemcanariseifthe6membersoftherequirementsteamdonotunderstandthesubtletiesoftheterminologyofthedomain.Onewaytosolvetheproblemwithterminologyistobuildaglossary.Theinitialentriesareinsertedwhiletheteamlearnstheapplicationdomain.Thentheglossaryisupdatedwheneverthemembersoftherequirementsteamencounternewterminology.Notonlydoessuchaglossaryreduceconfusionbetweenclientanddevelopers,italsoisusefulinlesseningmisunderstandingsbetweenmembersofthedevelopmentteam.Oncetherequirementsteamhaveacquiredfamiliaritywiththedomain,thenextstepisforthemtostarttodeterminetheclientsneeds,thatis,requirementselicitation.Elicitationtechniqueasfollows:Interviews.Themembersoftherequirementsteammeetwithmembersoftheclientorganizationuntiltheyareconvincedthattheyhaveelicitedallrelevantinformationfromtheclientandfutureusersoftheproduct.Therearetwobasictypesofinterview,structuredandunstructured.Inastructuredinterview,specific,preplanned,close-endedquestionsareposed.Inanunstructuredinterview,open-endedquestionsareasked,toencouragethepersonbeinginterviewedtospeakout.Someofthesefactsmightnothavecometolighthadtheinterviewbeenmorestructured.Atthesametime,itisnotagoodideaiftheinterviewistoounstructured.Therefore,questionsshouldbeposedinsuchawayastoencouragethepersonbeinginterviewedtogivewide-ranginganswersbutwithinthecontextoftheinformationneededbytheinterviewer.Conductingagoodinterviewisnotalwayseasy.First,theinterviewermustbefamiliarwiththeapplicationdomain.Second,thereisnopointininterviewingamemberoftheclientorganizationiftheintervieweralreadyhasmadeuphisorhermindregardingtheclientsneeds.Nomatterwhatheorshepreviouslyhasbeentoldorlearnedbyothermeans,theinterviewermustapproacheveryinterviewwiththeintentionoflisteningcarefullytowhatthepersonbeinginterviewedhastosaywhilefirmlysuppressinganypreconceivednotionsregardingtheclientcompanyortheneedsoftheclientsandpotentialusesofthesoftwareproducttobebuilt.7Scenarios.Ascenarioisawayausermightutilizethetargetproducttoaccomplishsomeobjective.Ascenariocanbedepictedinanumberofways.Onetechniqueissimplytolisttheactionscomprisingthescenario.Anothertechniqueistosetupastoryboard,aseriesofdiagramsdepictingthesequenceofevents.Theycandemonstratethebehavioroftheproductinawaythatiscomprehensibletotheuser.Thiscanresultinadditionalrequirementscomingtolight,asintheweight-lossplannerexample.Becausescenarioscanbeunderstoodbyusers,theutilizationofscenarioscanensurethattheclientandusersplayanactiverolethroughouttherequirementsanalysisprocess.Afterall,theaimoftherequirementsanalysisphaseistoelicittherealneedsoftheclient,andtheonlysourceofthisinformationistheclientandtheusers.Scenarios(ormoreprecisely,usecases)playanimportantroleinobject-orientedanalysis.Tosendaquestionnairetotherelevantmembersoftheclientorganization.Thistechniqueisusefulwhentheopinionsof,say,hundredsofindividualsneedtobedetermined.Furthermore,acarefullythought-outwrittenanswermaybemoreaccuratethananimmediateverbalresponsetoaquestionposedbyaninterviewer.However,anunstructuredinterviewconductedbyamethodicalinterviewerwholistenscarefullyandposesquestionsthatexpandoninitialresponsesusuallyyieldsfarbetterinformationthanathoughtfullywordedquestionnaire.Becausequestionnairesarepreplanned,thereisnowaythataquestioncanbeposedinresponsetoananswer.Toexaminethevariousformsusedbytheclient.Forexample,aforminaprintshopmightreflectpressnumber,paperrollsize,humidity,inktemperature,papertension,andsoon.Thevariousfieldsinthisformshedlightontheflowofprintjobsandtherelativeimportanceofthestepsintheprintingprocess.Otherdocuments,suchasoperatingproceduresandjobdescriptions,alsocanbepowerfultoolsfor3findingoutexactlywhatisdoneandhow.Suchcomprehensiveinformationregardinghowtheclientcurrentlydoesbusinesscanbeextraordinarilyhelpfulindeterminingtheclients8needs.Therefore,carefulperusalofclientdocumentationshouldneverbeoverlookedasasourceofinformationthatcanleadtoanaccurateassessmentoftheclientsneeds.Tosetupvideotapecameraswithintheworkplacetorecord(withthepriorwrittenpermissionofthosebeingobserved)exactlywhatisbeingdone.Onedifficultyofthistechniqueisthatitcantakealongtimetoanalyzethetapes.Ingeneral,oneormoremembersoftherequirementsanalysisteamhastospendanhourplayingbackthetapeforeveryhourthatthecamerasrecord.Thistimeisinadditiontowhatisneededtoassesswhatwasobserved.Moreseriously,thistechniquehasbeenknowntobackfirebadlybecauseemployeesmayviewthecamerasasanunwarrantedinvasionofprivacy.Itisimportantthattherequirementsanalysisteamhavethefullcooperationofallemployees;itcanbeextremelydifficulttoobtainthenecessaryinformationifpeoplefeelthreatenedorharassed.Thepossiblerisksshouldbeconsideredcarefullybeforeintroducingcamerasor,forthatmatter,takinganyotheractionthathasthepotentialtoangeremployees.Aninitialsetofrequirementshasbeenelicited,thenextstepistorefinethem,aprocesscalledrequirementsanalysis.Themembersoftherequirementsteamdiscussthelistofrequirementswiththevariousindividualsinterviewedtodetermineifanythinghasbeenomitted.Then,becausethemostaccurateandpowerfulrequirementsanalysistechniqueisrapidprototyping,arapidprototypeisbuilt.Arapidprototypeishastilybuiltsoftwarethatexhibitsthekeyfunctionalityofthetargetproduct.Theclientandintendedusersoftheproductnowexperimentwiththerapidprototype,whilemembersofthedevelopmentteamwatchandtakenotes.Basedontheirhands-onexperience,userstellthedevelopershowtherapidprototypesatisfiestheirneedsand,moreimportant,identifytheareasthatneedimprovement.Thedeveloperschangetherapidprototypeuntilbothsidesareconvincedthattheneedsoftheclientareaccuratelyencapsulatedintherapidprototype.Therapidprototypethenisusedasthebasisfordrawingupthespecifications.Animportantaspectoftherapidprototypingmodelisembodiedinthewordrapid.The9wholeideaistobuildtheprototypeasquicklyaspossible.Afterall,thepurposeoftherapidprototypeistoprovidetheclientwithanunderstandingoftheproduct,andthesooner,thebetter.Itdoesnotmatteriftherapidprototypehardlyworks,ifitcrasheseveryfewminutes,orifthescreenlayoutsarelessthanperfect.Thepurposeoftherapidprototypeistoenabletheclientandthedeveloperstoagreeasquicklyaspossibleonwhattheproductistodo.Therefore,anyimperfectionsintherapidprototypemaybeignored,providedtheydonotseriouslyimpairthefunctionalityoftherapidprototypeandtherebygiveamisleadingimpressionofhowtheproductwillbehave.Onedifficultywithrapidprototypingisthattheeasewithwhichchangesgenerallycanbemadetoarapidprototypemayencouragetheclienttorequestallsortsofmajorchangestothedeliveredoperational-qualityversionoftheproduct.Furthermore,theclientmayexpectthechangestobeimplementedasrapidlyaschangestotherapidprototype.Arelatedchallengeishavingtoexplaintotheclientthattherapidprototypeisnotofoperationalqualityandtheclientwillhavetowaitfortheoperational-qualityversion,eventhoughtherapidprototypeappearstodoeverythingneeded.Beforerapidprototypingis

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论