Design Patterns 设计模式

Design Patterns 设计模式

ID:40199666

大小:605.87 KB

页数:36页

时间:2019-07-25

Design Patterns 设计模式_第1页
Design Patterns 设计模式_第2页
Design Patterns 设计模式_第3页
Design Patterns 设计模式_第4页
Design Patterns 设计模式_第5页
资源描述:

《Design Patterns 设计模式》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、2012/11/19Monday设计模式分类标准1设计模式有两种分类标准,按用途来分:2按scope来分,主要分成类模式和对象模式两类。a)类模式处理类和其子类之间的关系,这种关系一般是通过继承实现的,因此在编译时就已经确定。b)对象模式处理对象间的关系,这种关系可在运行时修改,更灵活。c)因为大部分的模式都用到了继承,因此只有少数几个模式被认为是类模式。Classpatternsdealwithrelationshipsbetweenclassesandtheirsubclasses.Theserelationshipsareestablishedthroughinheritan

2、ce,sotheyarestatic—fixedatcompile-time.Objectpatternsdealwithobjectrelationships,whichcanbechangedatrun-timeandaremoredynamic.Almostallpatternsuseinheritancetosomeextent.Sotheonlypatternslabeled"classpatterns"arethosethatfocusonclassrelationships.NotethatmostpatternsareintheObjectscope.3Anobje

3、ctpackagesbothdataandtheproceduresthatoperateonthatdata.Theproceduresaretypicallycalledmethodsoroperations.Anobjectperformsanoperationwhenitreceivesarequest(ormessage)fromaclient.1Requestsaretheonlywaytogetanobjecttoexecuteanoperation.Operationsaretheonlywaytochangeanobject'sinternaldata.Becau

4、seoftheserestrictions,theobject'sinternalstateissaidtobeencapsulated;itcannotbeaccesseddirectly,anditsrepresentationisinvisiblefromoutsidetheobject.2面向对象设计的难点:decomposingasystemintoobjects,可考虑的因素太多,又没有唯一合适的标准。3Manyobjectsinadesigncomefromtheanalysismodel.Butobject-orienteddesignsoftenendupwith

5、classesthathavenocounterpartsintherealworld.Someofthesearelow-levelclasseslikearrays.Othersaremuchhigher-level.Forexample,theComposite(183)patternintroducesanabstractionfortreatingobjectsuniformlythatdoesn'thaveaphysicalcounterpart.Strictmodelingoftherealworldleadstoasystemthatreflectstoday'sr

6、ealitiesbutnotnecessarilytomorrow's.Theabstractionsthatemergeduringdesignarekeytomakingadesignflexible.4Everyoperationdeclaredbyanobjectspecifiestheoperation'sname,theobjectsittakesasparameters,andtheoperation'sreturnvalue.Thisisknownastheoperation'ssignature.Thesetofallsignaturesdefinedbyanob

7、ject'soperationsiscalledtheinterfacetotheobject.5Atypeisanameusedtodenoteaparticularinterface.6Therun-timeassociationofarequesttoanobjectandoneofitsoperationsisknownasdynamicbinding.7,dynamicbindingletsyousubstituteobjectsthathaveidenti

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。