汇编语言对象入门中英文对照外文翻译文献.docx

上传人:b****2 文档编号:1696764 上传时间:2023-05-01 格式:DOCX 页数:11 大小:25.82KB
下载 相关 举报
汇编语言对象入门中英文对照外文翻译文献.docx_第1页
第1页 / 共11页
汇编语言对象入门中英文对照外文翻译文献.docx_第2页
第2页 / 共11页
汇编语言对象入门中英文对照外文翻译文献.docx_第3页
第3页 / 共11页
汇编语言对象入门中英文对照外文翻译文献.docx_第4页
第4页 / 共11页
汇编语言对象入门中英文对照外文翻译文献.docx_第5页
第5页 / 共11页
汇编语言对象入门中英文对照外文翻译文献.docx_第6页
第6页 / 共11页
汇编语言对象入门中英文对照外文翻译文献.docx_第7页
第7页 / 共11页
汇编语言对象入门中英文对照外文翻译文献.docx_第8页
第8页 / 共11页
汇编语言对象入门中英文对照外文翻译文献.docx_第9页
第9页 / 共11页
汇编语言对象入门中英文对照外文翻译文献.docx_第10页
第10页 / 共11页
汇编语言对象入门中英文对照外文翻译文献.docx_第11页
第11页 / 共11页
亲,该文档总共11页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

汇编语言对象入门中英文对照外文翻译文献.docx

《汇编语言对象入门中英文对照外文翻译文献.docx》由会员分享,可在线阅读,更多相关《汇编语言对象入门中英文对照外文翻译文献.docx(11页珍藏版)》请在冰点文库上搜索。

汇编语言对象入门中英文对照外文翻译文献.docx

汇编语言对象入门中英文对照外文翻译文献

中英文资料外文翻译文献

1.IntroductionToObjects

1.1Theprogressofabstraction

Allprogramminglanguagesprovideabstractions.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.2Anobjecthasaninterface

Aristotlewasprobablythefirsttobeginacarefulstudyoftheconceptoftype;hespokeof“theclassoffishesandtheclassofbirds.”Theideathatallobjects,whilebeingunique,arealsopartofaclassofobjectsthathavecharacteristicsandbehaviorsincommonwasuseddirectlyinthefirstobject-orientedlanguage,Simula-67,withitsfundamentalkeywordclassthatintroducesanewtypeintoaprogram.

Simula,asitsnameimplies,wascreatedfordevelopingsimulationssuchastheclassic“banktellerproblem.”Inthis,youhaveabunchoftellers,customers,accounts,transactions,andunitsofmoney—alotof“objects.”Objectsthatareidenticalexceptfortheirstateduringaprogram’sexecutionaregroupedtogetherinto“classesofobjects”andthat’swherethekeywordclasscamefrom.Creatingabstractdatatypes(classes)isafundamentalconceptinobject-orientedprogramming.Abstractdatatypesworkalmostexactlylikebuilt-intypes:

Youcancreatevariablesofatype(calledobjectsorinstancesinobject-orientedparlance)andmanipulatethosevariables(calledsendingmessagesorrequests;yousendamessageandtheobjectfiguresoutwhattodowithit).Themembers(elements)ofeachclasssharesomecommonality:

everyaccounthasabalance,everytellercanacceptadeposit,etc.Atthesametime,eachmemberhasitsownstate:

eachaccounthasadifferentbalance,eachtellerhasaname.Thus,thetellers,customers,accounts,transactions,etc.,caneachberepresentedwithauniqueentityinthecomputerprogram.Thisentityistheobject,andeachobjectbelongstoaparticularclassthatdefinesitscharacteristicsandbehaviors.

So,althoughwhatwereallydoinobject-orientedprogrammingiscreatenewdatatypes,virtuallyallobject-orientedprogramminglanguagesusethe“class”keyword.Whenyouseetheword“type”think“class”andviceversa.

Sinceaclassdescribesasetofobjectsthathaveidenticalcharacteristics(dataelements)andbehaviors(functionality),aclassisreallyadatatypebecauseafloatingpointnumber,forexample,alsohasasetofcharacteristicsandbehaviors.Thedifferenceisthataprogrammerdefinesaclasstofitaproblemratherthanbeingforcedtouseanexistingdatatypethatwasdesignedtorepresentaunitofstorageinamachine.Youextendtheprogramminglanguagebyaddingnewdatatypesspecifictoyourneeds.Theprogrammingsystemwelcomesthenewclassesandgivesthemallthecareandtype-checkingthatitgivestobuilt-intypes.

Theobject-orientedapproachisnotlimitedtobuildingsimulations.Whetherornotyouagreethatanyprogramisasimulationofthesystemyou’redesigning,theuseofOOPtechniquescaneasilyreducealargesetofproblemstoasimplesolution.

Onceaclassisestablished,youcanmakeasmanyobjectsofthatclassasyoulike,andthenmanipulatethoseobjectsasiftheyaretheelementsthatexistintheproblemyouaretryingtosolve.Indeed,oneofthechallengesofobject-orientedprogrammingistocreateaone-to-onemappingbetweentheelementsintheproblemspaceandobjectsinthesolutionspace.

Buthowdoyougetanobjecttodousefulworkforyou?

Theremustbeawaytomakearequestoftheobjectsothatitwilldosomething,suchascompleteatransaction,drawsomethingonthescreen,orturnonaswitch.Andeachobjectcansatisfyonlycertainrequests.Therequestsyoucanmakeofanobjectaredefinedbyitsinterface,andthetypeiswhatdeterminestheinterface.Asimpleexamplemightbearepresentationofalightbulb:

Light

On()

Off()

Lightlt=newLight();

lt.on();

Theinterfaceestablisheswhatrequestsyoucanmakeforaparticularobject.However,theremustbecodesomewheretosatisfythatrequest.This,alongwiththehiddendata,comprisestheimplementation.Fromaproceduralprogrammingstandpoint,it’snotthatcomplicated.Atypehasamethodassociatedwitheachpossiblerequest,andwhenyoumakeaparticularrequesttoanobject,thatmethodiscalled.Thisprocessisusuallysummarizedbysayingthatyou“sendamessage”(makearequest)toanobject,andtheobjectfiguresoutwhattodowiththatmessage(itexecutescode).

Here,thenameofthetype/classisLight,thenameofthisparticularLightobjectislt,andtherequeststhatyoucanmakeofaLightobjectaretoturniton,turnitoff,makeitbrighter,ormakeitdimmer.YoucreateaLightobjectbydefininga“reference”(lt)forthatobjectandcallingnewtorequestanewobjectofthattype.Tosendamessagetotheobject,youstatethenameoftheobjectandconnectitto

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

当前位置:首页 > 人文社科 > 法律资料

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2