您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > 计算机专业毕业设计论文外文文献中英文翻译――java对象
1.IntroductionToObjects1.1TheprogressofabstractionAllprogramminglanguagesprovideabstractions.Itcanbearguedthatthecomplexityoftheproblemsyou’reabletosolveisdirectlyrelatedtothekindandqualityofabstraction.By“kind”Imean,“Whatisitthatyouareabstracting?”Assemblylanguageisasmallabstractionoftheunderlyingmachine.Manyso-called“imperative”languagesthatfollowed(suchasFORTRAN,BASIC,andC)wereabstractionsofassemblylanguage.Theselanguagesarebigimprovementsoverassemblylanguage,buttheirprimaryabstractionstillrequiresyoutothinkintermsofthestructureofthecomputerratherthanthestructureoftheproblemyouaretryingtosolve.Theprogrammermustestablishtheassociationbetweenthemachinemodel(inthe“solutionspace,”whichistheplacewhereyou’remodelingthatproblem,suchasacomputer)andthemodeloftheproblemthatisactuallybeingsolved(inthe“problemspace,”whichistheplacewheretheproblemexists).Theeffortrequiredtoperformthismapping,andthefactthatitisextrinsictotheprogramminglanguage,producesprogramsthataredifficulttowriteandexpensivetomaintain,andasasideeffectcreatedtheentire“programmingmethods”industry.Thealternativetomodelingthemachineistomodeltheproblemyou’retryingtosolve.EarlylanguagessuchasLISPandAPLchoseparticularviewsoftheworld(“Allproblemsareultimatelylists”or“Allproblemsarealgorithmic,”respectively).PROLOGcastsallproblemsintochainsofdecisions.Languageshavebeencreatedforconstraint-basedprogrammingandforprogrammingexclusivelybymanipulatinggraphicalsymbols.(Thelatterprovedtobetoorestrictive.)Eachoftheseapproachesisagoodsolutiontotheparticularclassofproblemthey’redesignedtosolve,butwhenyoustepoutsideofthatdomaintheybecomeawkward.Theobject-orientedapproachgoesastepfurtherbyprovidingtoolsfortheprogrammertorepresentelementsintheproblemspace.Thisrepresentationisgeneralenoughthattheprogrammerisnotconstrainedtoanyparticulartypeofproblem.Werefertotheelementsintheproblemspaceandtheirrepresentationsinthesolutionspaceas“objects.”(Youwillalsoneedotherobjectsthatdon’thaveproblem-spaceanalogs.)Theideaisthattheprogramisallowedtoadaptitselftothelingooftheproblembyaddingnewtypesofobjects,sowhenyoureadthecodedescribingthesolution,you’rereadingwordsthatalsoexpresstheproblem.Thisisamoreflexibleandpowerfullanguageabstractionthanwhatwe’vehadbefore.Thus,OOPallowsyoutodescribetheproblemintermsoftheproblem,ratherthanintermsofthecomputerwherethesolutionwillrun.There’sstillaconnectionbacktothecomputer:eachobjectlooksquiteabitlikealittlecomputer—ithasastate,andithasoperationsthatyoucanaskittoperform.However,thisdoesn’tseemlikesuchabadanalogytoobjectsintherealworld—theyallhavecharacteristicsandbehaviors.AlanKaysummarizedfivebasiccharacteristicsofSmalltalk,thefirstsuccessfulobject-orientedlanguageandoneofthelanguagesuponwhichJavaisbased.Thesecharacteristicsrepresentapureapproachtoobject-orientedprogramming:1.Everythingisanobject.Thinkofanobjectasafancyvariable;itstoresdata,butyoucan“makerequests”tothatobject,askingittoperformoperationsonitself.Intheory,youcantakeanyconceptualcomponentintheproblemyou’retryingtosolve(dogs,buildings,services,etc.)andrepresentitasanobjectinyourprogram.2.Aprogramisabunchofobjectstellingeachotherwhattodobysendingmessages.Tomakearequestofanobject,you“sendamessage”tothatobject.Moreconcretely,youcanthinkofamessageasarequesttocallamethodthatbelongstoaparticularobject.3.Eachobjecthasitsownmemorymadeupofotherobjects.Putanotherway,youcreateanewkindofobjectbymakingapackagecontainingexistingobjects.Thus,youcanbuildcomplexityintoaprogramwhilehidingitbehindthesimplicityofobjects.4.Everyobjecthasatype.Usingtheparlance,eachobjectisaninstanceofaclass,inwhich“class”issynonymouswith“type.”Themostimportantdistinguishingcharacteristicofaclassis“Whatmessagescanyousendtoit?”5.Allobjectsofaparticulartypecanreceivethesamemessages.Thisisactuallyaloadedstatement,asyouwillseelater.Becauseanobjectoftype“circle”isalsoanobjectoftype“shape,”acircleisguaranteedtoacceptshapemessages.Thismeansyoucanwritecodethattalkstoshapesandautomaticallyhandleanythingthatfitsthedescriptionofashape.ThissubstitutabilityisoneofthepowerfulconceptsinOOP.Boochoffersanevenmoresuccinctdescriptionofanobject:Anobjecthasstate,behaviorandidentity.Thismeansthatanobjectcanhaveinternaldata(whichgivesitstate),methods(toproducebehavior),andeachobjectcanbeuniquelydistinguishedfromeveryotherobject—toputthisinaconcretesense,eachobjecthasauniqueaddressinmemory.1.2AnobjecthasaninterfaceAristotlewasprobablythefirsttobeginacarefulstudyoftheconceptoftype;hespokeof“theclassoffishesandtheclassofbirds.”Theideathatallobjects,whilebeingunique,arealsopartofaclassofobjectsthathavecharacteristicsandbehaviorsincommonwasuseddirectlyinthefirstobject-orientedlanguage,Simula-67,withitsfundamentalkeywordclassthatintroducesanewtypeintoaprogram.Simula,asitsnameimplies,wascreatedfordevelopingsimulationssuchastheclassic“banktellerproblem.”Inthis,youhaveabunchoftellers,customers,accounts,transactions,andunitsofmoney—alotof“objects.”Objectsthatareidenticalexceptfortheirstateduringaprogram’sexecutionaregroupedtogetherinto“classesofobjects”andt
本文标题:计算机专业毕业设计论文外文文献中英文翻译――java对象
链接地址:https://www.777doc.com/doc-3533020 .html