面向对象中外文翻译.docx
《面向对象中外文翻译.docx》由会员分享,可在线阅读,更多相关《面向对象中外文翻译.docx(18页珍藏版)》请在冰豆网上搜索。
面向对象中外文翻译
学院(部):
计算机科学与工程学院
专业班级:
计算机09-2班
学生姓名:
指导教师:
2013年5月29日
Object-orientedanalysisanddesign
Thebasicconceptofobject-orientedtechnologyandthebasicmethod
1.1softwaredevelopmentmethod
Computerafterbirth,computertechnologyhasbeendevelopinginhighspeedcondition,thedevelopmentofcomputerscienceandtechnologybyoriginalonlydependsonthedevelopmentofhardwaretorelyingmoreonsoftwaredevelopment.Infact,thedevelopmentofsoftwaretechnologyhasexperiencedmorethangenerationprocess.
Firstgeneration(50to60softhe20thcentury),inprogramminglanguagessuchasFORTRANandALGOLtechnologymarkedbyalgorithm
Generationtogeneration.Atthattime,theprogramdesignonpeopleallcreativetalents,allrelyontipsandtricks.Softwareproductivityisverylow,basedonthealgorithmprocedureisverydifficulttounderstand,programmerswritetheirownprogramoveraperiodoftimeevenafteroneselfalsolooknottounderstand,thistothesoftwaremodifications,maintenancebringgreatdifficulties.Soattheendofthe60sinthe"softwarecrisis".
Secondgeneration(inthelate1970sto80sprevailing),suchasPASCAL,andCOBOLprogramminglanguageandrelationaldatabasemanagementsystemforastructuredsystemanalysisanddesigntechniques.Inordertoovercomethesoftwarecrisis,peoplemadeeffortstomainlyfromthefollowingtwodirections:
MethodsfromtheAngleofthemanagementtoimprovethesoftwaredevelopment,softwareengineeringmethodisproposed,andgreatlyimprovethequalityandmaintainabilityofthesoftware.
Secondistofocusontheanalysisinthesoftwaredevelopmentprocessanddesignmethodofresearchandimprovement.Importantachievementsinthisfieldisdevelopedinthe70stherageofstructureddevelopmentmethodofstructuredsystemanalysisanddesigntechniques.
Thirdgeneration(inthe80sisstillprevalent)representedbySmalltalk,c++object-orientedsoftwaredevelopmentmethods.
Question1:
whatisonthedevelopmentdynamicsofobject-orientedsoftwaredevelopmentmethods?
Traditionalstructuredprogrammingalgorithmasthecore,theoriginaliscloselyrelatedtothedataandseparatetotheoperationofthedata,itisdifficulttomaintaintheconsistencyofdataandoperation,itssoftwaredevelopmentmethodalsodoesnotconformtothenaturalthinkinghabits,thedesignedsoftwaresystemsolutionspaceandtheproblemspace,theexpanded,difficulttounderstand,modify,andleadtoproblemsintermsofprogramcomplexityandsoftwarecrisis.Inordertotranscendprogramcomplexitybarrier,overcomethesoftwarecrisis,object-orientedsoftwaredevelopmentmethodsareputforward.
Question2:
whataretheadvantagesoftheobject-orientedsoftwaredevelopmentmethod?
Object-orienteddevelopmentmethodtochangethepasttraditionalonthebasisoffunctionanalysisandfunctiondecompositionofprocessorientedstructuralanalysisanddesignmethodofobject-orienteddevelopmentmethodtosimulatethewaypeopleunderstandanddealwiththeobjectiveworldtoanalyzetheproblem,thesystemasaseriesofcollectionsofobjects,itsobject-orienteddesignandanalysisofresultsismappedtoastructureofobject-orientedimplementationtool,hasamoredirectcorrespondencetomappingprocess,theanalysts,designers,andprogrammerscanusethesameconcept,sothattheobjectorientedsoftwaredevelopmentcansimulatemorenaturallytotheactivitiesoftheobjectiveworld,makingtheproblemspaceandsolutionspaceonthestructureassoonaspossible.Therefore,adoptingtheobject-orientedmethodcanmoreeffectivelydevelopinglargesoftwaresystems.Object-orientedmethodofencapsulation,inheritanceandpolymorphismmechanismnotonlytosupportsoftwarereuse,andthesoftwaremaintenance,reliableandefficientsoftwaresystemwhichcanrealizeflexiblemanufacturing,bettertoovercomethesoftwarecrisis.Therefore,ithasbecomeamaturemethodwidelyusedinsoftwaredevelopment.Bytheendofthe20thcentury,objectorientedsoftwareengineeringdevelopmentgraduallymature,especiallytheformationoftheunifiedmodelinglanguage(UML)standardandwidelyused,theobject-orientedsoftwaredevelopmentmethodshavebecomethemainstreamofthesoftwaredevelopmenttechnology.
1.2thebasicconceptofobject-oriented
Object:
(1)abstractrepresentationsoftheobjectsisanobjectiveentityattributesoftheobjectisdescribedbythedataandthedatafortheoperationofthebehavioroftwoparts.
(2)class:
classisacollectionofobjectswiththesamepropertiesandbehaviorofabstractdescription;Internalincludingattributesandbehavioroftwomainparts.
(3)example:
classesistohavethesamepropertiesandbehaviorofasetofabstractdescriptionsofobjects.Therefore,classescanbeusedasauser-definedtypeandcreatetheobjectmodel,andaccordingtothemodelcreatedbytheactualexampleofaspecificobjectisaclass,oftenreferredtoasexamples.
(4)themessage:
themessageistorequestanobjectitcontainsaprocessingoperationontheinstructioninformation.Essenceistotheoperationoftheobjectofaclassfunctioncall,thecalltoamethod.
Forexample,studentS1;S1.Thedisplay()isamessage.
Anewsgenerallyconsistsofthreeparts:
receivingamessageobjectname,theparametersofthefunctionname,function,operation.
(5)thethreebasiccharacteristicsofobject-orientedtechnology:
encapsulation,inheritance,andpolymorphism
(6)encapsulation:
theso-calledencapsulationistheobject'spropertiesandbehaviorcombinedintoasingleunit,totheoutsideworldcannotdirectlyaccessormodifythedataandcode,theoutsideworldonlythroughobjectprovidestheinterfacefunctiontochangetheattributesoftheobjectorobtainingdata,itisrealizedthemessageishidden.
(7)inheritance:
ifinadefinedontheclass,addsomespecialattributeoroperation,canformanewclass,thisclassisnotonlyinheritedtheformerallcharacteristicsofaclass,andwithnewfeatures,soasaspecialcaseoftheclassbefore,isinfrontofaclasstoinherit.Aclassknownastheparentclass,beforethenewclassiscalledasubclass.Throughinheritancerelationshipcanformatypehierarchy,calledinheritancestructure.
Polymorphism(8):
indifferentclasses,thesamefunctionnametorealizefunctionsofdifferentfunctionsavailable.Polymorphismsoftheadvantages:
high-levelcode(algorithm)writeitonlyonceandthelowercanbereusedformanytimes,canimprovetheprogrammingflexibilityandefficiency.
Object-orientedprogramming
1.threemajormechanismsofobjectorientedtechnology(characteristics):
(1)encapsulationmechanismandthedesignoftheclass:
theso-calledencapsulatedobjectattributedataandoperationmethodisallowedtobecombinedintoasingleunit,totheoutsideworldcannotdirectlyaccessormodifythedataandcode,theoutsideworldonlythroughobjectprovidestheinterfacefunctiontochangetheattributesoftheobjectorobtainingdata,itimplementsthemessagehidden;Inc++,classistosupportthedataencapsulationtool,allowingdesignclassdescriptionstoabstractasetwiththesamepropertiesandbehavioroftheobject,namelycanencapsulateasetofobjectsintheclassofcommonpropertiesandmethods.Thus,classisthetooltorealizedataencapsulation,objectistherealizationofdataencapsulation.Nopackage,noobject-orientedtechnology.
Classmemberstoaccesstheprincipleis:
(1)defineaclass,thedatamembersandmemberfunctionsisthedefaultaccessprivatemembers.
(2)amemberfunctioncanbedirectaccesstothemembersofthesamevariablesandcallstomembersofthesamefunction,neednotaddobjectnamebeforethefunctionname.(3)membersoftheprivateorprotectedmemberislimitedtothescopeoftheclassthatthebodyandtheclassmemberfunctions;Nonmemberfunctionsshouldbedefinedasaclassoffriendstoaccesstheprivatemembersofaclassmemberfunction.(4)membersofthepublicscopenotonlyincludestheclassbody,alsoincludestheuseoftheobjectwhichitbelongs.Canaccesstopublicmembersoutsideclass,butmustbebeforethemembernameplustheobjectname.
(2)theinheritancemechanismandderivedclassdefinition:
theso-calledinheritanceisallowedonanexistingclass,addsomespecialattributesoroperations,toderiveanewclass.Notonlycanthederivedclassinheritsabaseclassmember,andcandefinenewmember,socanbeasspecialclassofaclassbefore.Aclassknownastheparentclass,beforethenewclassiscalledasubclass.Throughinheritancerelationshipcanformatypehierarchy,calledinheritancestructure.InheritanceisoneoftheSharedpropertiesbetweenclassesandservicemechanism.
classperson//Thebaseclass
{protected:
charname[11];
charsex;
intage;
public:
person(){cout<<“person”<~person(){cout<<“deleteperson”<intGetage(){return20;}}
classStudent:
publicperson
{private:
charid[9];
floatscore;
public:
student(){cout<<“student”<~student(){cout<<“deletestudent”<floatGetScore{returnscore;}
}
voidF(person*q){ q->Getage(); }
voidmain()
{person*p;
students;
p=&s;
F(p);//p->Getage();
}
Theresults:
person
student
20
deletestudent
deleteperson
2.Thedefinitionofmechanismofpolymorphismandvirtualfunctions:
Polymorphismreferstotheclasshierarchyinthesameclassordifferentclasses,canusethesamefunctionnamedifferentoperatingfunctionality,whichyoucanusethesamecallwaytoinvokethesefunctionswiththesamenamewithdifferentfunction