- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
* * * * * 在面向对象设计过程中,设计人员必须确定实现关联的具体策略 * * * * * * * * 把一个元素压入栈,等价于在表尾加入一个元素;把一个元素弹出栈,相当于从表尾移走一个元素。但是,与此同时,也继承了一些不需要的表操作。例如,从表头移走一个元素或在表头增加一个元素。万一用户错误地使用了这类操作,Stack类将不能正常工作。 class List{public:void add( ); void remove(); Void first(); Void last(); };class Stack: public List{…}; 如果你只想把继承作为实现操作共享的一种手段,则利用委托(即把一类对象作为另一类对象的属性,从而在两类对象间建立组合关系)也可以达到同样目的,而且这种方法更安全。 // 正确的设计class Stack{public:void push(void) { m_list.last(); m_list.add(); }void pop(void) {m_list.last(); m_list.remove(); }private:List m_list;} * “A design pattern describes a problem that occurs repetitively and then describes a solution to that problem in such a way that that it can be used over and over without ever doing it the same way twice” - Christopher Alexander * 模式具有: 名称(name):描述问题和解决方案的一个或两个单词 问题(problem): 什么时候应用模式 解决方案(solution): 描述设计元素、元素间的关系、职责和协作 结果和交易 (Consequences and trade-offs):应用模式返回的结果 更多的信息请见Erich Gamma等编著的“Design Patterns” - Elements of Reusable Object Oriented Software ,ISBN0-201-63361-2 或中文版《设计模式:可复用面向对象软件的基础》, Erich Gamma等编著,机械工业出版社,?ISBN:?7111075757 * Design make it easier to use successful designs and architectures * 观察者看作监听器(listener) ,主题看作是事件源(event source) 图中,主题是数据(a = 50 …) , 有三个观察者——饼图、图表和柱状图 * * Observer pattern is applicable when in a system a change to one object requires changing others and you don`t know how many objects need to be changed. The key objects are subject and observer. Subject should be able to notify other objects without making assumptions about who these objects are. The subject notifies its observers whenever a change occurs that could make its observers` state inconsistent with its own. After being informed of a change in the concrete subject, a concrete observer may query the subject information. Concrete observer uses this information to update its state with that of the subject. * Normally in the observer pattern all the concrete observers gets state from the subject with getstate message. But here we directly give the state
您可能关注的文档
最近下载
- Unit3 Culture time&Cartoon time(课件)六年级英语上册(译林版三起).pptx VIP
- 驾照考试科目一试题1000题(含标准答案).pdf VIP
- Acer宏碁显示器XZ SeriesXZ396QUP快速指南使用手册.pdf
- 矿山安全法与煤炭法.ppt VIP
- 哮喘患者急救知识.pptx VIP
- 常见瓷砖修复培训课件.pptx VIP
- 残疾儿童送教上门教案.doc VIP
- Yamaha 雅马哈 乐器音响 RX-A4A User Guide 用户手册.pdf
- 一种创伤弧菌噬菌体13VV501A、微生态制剂及其应用.pdf VIP
- 2020-2021学年北京市延庆区第二学期(下期)期末考试八年级(初二)数学试题.docx
文档评论(0)