已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2027年江西庐山职业学院高职单招职业技能考试题库及完整答案详解(历年真题)
- 初中八年级英语上册Unit2 Grammar Focus语法教学教案
- 2025年防城港市防城区住房和城乡建设局人员招聘笔试试题及答案详解
- 2026年桂林市叠彩区住房和城乡建设局人员招聘笔试参考题库及答案详解
- 九年级英语中考语法精讲:主谓一致原则的深度解析与跨学科应用教案
- 初中信息技术八年级《段落格式设置-让倡议书更“靓”起来》教学设计
- 初中八年级英语上册 Unit 8 How do you make a banana milk shake Section B (2a2e) 阅读课深度探究教案
- 宾馆员工考勤与绩效考核手册
- 2026人教版五年级数学上册第四单元第4课《旋转(1)》教案
- 大学本科材料科学与工程专业《电子产品结构材料抗弯性能分析与优化》教学设计
- 临床镇痛药物的应用与管理
- 铸造工安全培训课件
- 安徽省2025年公需科目三安徽农业大学测验参考答案
- 2025云南省行政执法资格考试考前模拟题(含答案)
- 【鄂尔多斯】2024年内蒙古鄂尔多斯职业学院人才引进39人笔试附带答案详解
- 2024衡阳蒸湘区中小学教师招聘考试试题及答案
- 《齐齐哈尔烤肉制作工艺与服务规范》
- DB52T 1161-2016 贵州省旅游购物场所等级划分与评定
- 2024年广东省深圳市南山区中考英语三模试卷
- 男生殖系统肿瘤案例分析阴茎癌课件
- 钢板桩围堰设计计算
评论
0/150
提交评论