计算机专业毕业设计论文外文文献中英文翻译(Object)Word下载.doc

上传人:b****1 文档编号:13201322 上传时间:2022-10-08 格式:DOC 页数:13 大小:61KB
下载 相关 举报
计算机专业毕业设计论文外文文献中英文翻译(Object)Word下载.doc_第1页
第1页 / 共13页
计算机专业毕业设计论文外文文献中英文翻译(Object)Word下载.doc_第2页
第2页 / 共13页
计算机专业毕业设计论文外文文献中英文翻译(Object)Word下载.doc_第3页
第3页 / 共13页
计算机专业毕业设计论文外文文献中英文翻译(Object)Word下载.doc_第4页
第4页 / 共13页
计算机专业毕业设计论文外文文献中英文翻译(Object)Word下载.doc_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

计算机专业毕业设计论文外文文献中英文翻译(Object)Word下载.doc

《计算机专业毕业设计论文外文文献中英文翻译(Object)Word下载.doc》由会员分享,可在线阅读,更多相关《计算机专业毕业设计论文外文文献中英文翻译(Object)Word下载.doc(13页珍藏版)》请在冰豆网上搜索。

计算机专业毕业设计论文外文文献中英文翻译(Object)Word下载.doc

外文资料@#@Objectlandscapesandlifetimes@#@Technically,OOPisjustaboutabstractdatatyping,inheritance,andpolymorphism,butotherissuescanbeatleastasimportant.Theremainderofthissectionwillcovertheseissues.@#@Oneofthemostimportantfactorsisthewayobjectsarecreatedanddestroyed.Whereisthedataforanobjectandhowisthelifetimeoftheobjectcontrolled?

@#@Therearedifferentphilosophiesatworkhere.C++takestheapproachthatcontrolofefficiencyisthemostimportantissue,soitgivestheprogrammerachoice.Formaximumrun-timespeed,thestorageandlifetimecanbedeterminedwhiletheprogramisbeingwritten,byplacingtheobjectsonthestack(thesearesometimescalledautomaticorscopedvariables)orinthestaticstoragearea.Thisplacesapriorityonthespeedofstorageallocationandrelease,andcontrolofthesecanbeveryvaluableinsomesituations.However,yousacrificeflexibilitybecauseyoumustknowtheexactquantity,lifetime,andtypeofobjectswhileyou'@#@rewritingtheprogram.Ifyouaretryingtosolveamoregeneralproblemsuchascomputer-aideddesign,warehousemanagement,orair-trafficcontrol,thisistoorestrictive.@#@Thesecondapproachistocreateobjectsdynamicallyinapoolofmemorycalledtheheap.Inthisapproach,youdon'@#@tknowuntilrun-timehowmanyobjectsyouneed,whattheirlifetimeis,orwhattheirexacttypeis.Thosearedeterminedatthespurofthemomentwhiletheprogramisrunning.Ifyouneedanewobject,yousimplymakeitontheheapatthepointthatyouneedit.Becausethestorageismanageddynamically,atrun-time,theamountoftimerequiredtoallocatestorageontheheapissignificantlylongerthanthetimetocreatestorageonthestack.(Creatingstorageonthestackisoftenasingleassemblyinstructiontomovethestackpointerdown,andanothertomoveitbackup.)Thedynamicapproachmakesthegenerallylogicalassumptionthatobjectstendtobecomplicated,sotheextraoverheadoffindingstorageandreleasingthatstoragewillnothaveanimportantimpactonthecreationofanobject.Inaddition,thegreaterflexibilityisessentialtosolvethegeneralprogrammingproblem.@#@Javausesthesecondapproach,exclusively].Everytimeyouwanttocreateanobject,youusethenewkeywordtobuildadynamicinstanceofthatobject.@#@There'@#@sanotherissue,however,andthat'@#@sthelifetimeofanobject.Withlanguagesthatallowobjectstobecreatedonthestack,thecompilerdetermineshowlongtheobjectlastsandcanautomaticallydestroyit.However,ifyoucreateitontheheapthecompilerhasnoknowledgeofitslifetime.InalanguagelikeC++,youmustdetermineprogrammaticallywhentodestroytheobject,whichcanleadtomemoryleaksifyoudon’tdoitcorrectly(andthisisacommonprobleminC++programs).Javaprovidesafeaturecalledagarbagecollectorthatautomaticallydiscoverswhenanobjectisnolongerinuseanddestroysit.Agarbagecollectorismuchmoreconvenientbecauseitreducesthenumberofissuesthatyoumusttrackandthecodeyoumustwrite.Moreimportant,thegarbagecollectorprovidesamuchhigherlevelofinsuranceagainsttheinsidiousproblemofmemoryleaks(whichhasbroughtmanyaC++projecttoitsknees).@#@Therestofthissectionlooksatadditionalfactorsconcerningobjectlifetimesandlandscapes.@#@1Collectionsanditerators@#@Ifyoudon’tknowhowmanyobjectsyou’regoingtoneedtosolveaparticularproblem,orhowlongtheywilllast,youalsodon’tknowhowtostorethoseobjects.Howcanyouknowhowmuchspacetocreateforthoseobjects?

@#@Youcan’t,sincethatinformationisn’tknownuntilrun-time.@#@Thesolutiontomostproblemsinobject-orienteddesignseemsflippant:

@#@youcreateanothertypeofobject.Thenewtypeofobjectthatsolvesthisparticularproblemholdsreferencestootherobjects.Ofcourse,youcandothesamethingwithanarray,whichisavailableinmostlanguages.Butthere’smore.Thisnewobject,generallycalledacontainer(alsocalledacollection,buttheJavalibraryusesthatterminadifferentsensesothisbookwilluse“container”),willexpanditselfwhenevernecessarytoaccommodateeverythingyouplaceinsideit.Soyoudon’tneedtoknowhowmanyobjectsyou’regoingtoholdinacontainer.Justcreateacontainerobjectandletittakecareofthedetails.@#@Fortunately,agoodOOPlanguagecomeswithasetofcontainersaspartofthepackage.InC++,it’spartoftheStandardC++LibraryandissometimescalledtheStandardTemplateLibrary(STL).ObjectPascalhascontainersinitsVisualComponentLibrary(VCL).Smalltalkhasaverycompletesetofcontainers.Javaalsohascontainersinitsstandardlibrary.Insomelibraries,agenericcontainerisconsideredgoodenoughforallneeds,andinothers(Java,forexample)thelibraryhasdifferenttypesofcontainersfordifferent

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 法律文书 > 辩护词

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1