资源描述:
《pattern_examples》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、PresidencyReturnunique-instanceElection()ExamplestoAccompany:DesignPatternsElementsofReusableObject-OrientedSoftwareATCTowerFlight111Flight1011Flight112Flight747DesignPatterns-ElementsofReusableObject-OrientedSoftwarewaswrittenbyErichGamma,RichardHelm,RalphJohn
2、sonandJohnVlissides(alsoknownastheGangofFour,orGoF)ItwaspublishedbyAddison-Wesleyin1995,andisregardedasthefirsttextonSoftwareDesignPatterns.Non-SoftwareexamplesofthesepatternswerepublishedbyMichaelDuellinObjectMagazineinJuly,1997.Theexamplesherearetheresultofan
3、OOPSLA‘97workshopofNon-SoftwareExamplesofSoftwareDesignpatterns,conductedbyMichaelDuell,JohnGoodsenandLindaRising.Inadditiontotheworkshoporganizers,contributorstothisbodyofworkincludeBrianCampbell,JensColdeway,HelenKlein,JamesNoble,MichaelRichmond,andBobbyWoolf
4、.ÓAGCommunicationSystems-1999A-1AbstractFactorySheetmetalstampingStampingEquipmentequipmentisanexampleClientStampPart()(partslistforModel)ofanAbstractFactoryforcreatingautobodyparts.Usingrollerstochangethedies,theDiesconcreteclasscanbechanged.ThepossibleModel3R
5、ightDoorDieModel3LeftDoorDieModel3HoodDieModel2RightDoorDieModel2LeftDoorDieModel2HoodDieconcreteclassesareModel1RightDoorModel1LeftDoorModel1Hoodhoods,trunks,roofs,leftStampRightDoor()StampLeftDoor()StampHood()andrightfrontfenders,etc.Themasterpartslistensures
6、thatclasseswillbecompatible.NotethatanAbstractFactoryisacollectionofFactoryCreationalMethods.ThepurposeoftheAbstractFactoryistoprovideaninterfaceforcreatingfamiliesofrelatedobjectswithoutspecifyingconcreteclasses.ParticipantCorrespondence:TheMasterPartsListcorr
7、espondstotheclient,whichgroupsthepartsintoafamilyofparts.TheStampingEquipmentcorrespondstotheAbstractFactory,asitisaninterfaceforoperationsthatcreateabstractproductobjects.ThediescorrespondtotheConcreteFactory,astheycreateaconcreteproduct.Eachpartcategory(Hood,
8、Door,etc.)correspondstotheabstractproduct.Specificparts(i.e.,driversidedoorfor1998NihonseiSedan)correspondstotheconcreteproducts.Consequences:Concreteclassesareisolatedinthe