<<Design Patterns>> Gang of Four
One:Introduction:
One-1:Before delving into the some twenty pattern designs, it's necessary for ME(not for all readers) to get at some philosophies of OOD/OOP.
(1)Requests are the only way to get an object to execute an operation and Operations are the only way to change an object's internal data(state).this might appears going without saying,but I think it's important to kept in mind when programming.
(2)Interfaces of an object are preferably suggested to interact with the object's own data. I get this sense in practice. For example, the class Image, aggregates a

class Feature. when implementing interfaces in class Image, I'd better only deal with feature itself instead of letting Image's interfaces visit feature's data derecty.
(2)MVC使用了什么设计模式?
首先是观察者模式。其通过建立subscribe/notify机制,施加于view和model之间。当model里面的数据改变的时候,model应该通知依赖于这个model的所有views;然后每个view就更新自己。这个方法可以使“多个view依赖一个model时候,想创建一个新的依赖于此model的view“的时候使用。这样可以不重写这个model。
其次是组合模式。当一个view里面包含其他view,比如一个panel里面包含button,text等。这个nested views可以作为view的子类,可以用在任何父类被使用的地方。并作为一个整体被外部访问。
还有就是策略模式,其可以施加与view-controller之间。一个view使用一个controller的实例,每当view改变的时候(这里的改变包括很多,比如view的外观改变,行为改变(比如拒绝接受用户的输入等)等),对一个controller实例可以对其进行控制。
当然,MVC还可以使用工厂方法,装饰模式。前者可以为一个view生产指定的或默认的controller,后者可以给一个view添加scrolling。
<<Design Patterns>> Gang of Four的更多相关文章
- MapReduce Design Patterns(chapter 1)(一)
Chapter 1.Design Patterns and MapReduce MapReduce 是一种运行于成百上千台机器上的处理数据的框架,目前被google,Hadoop等多家公司或社区广泛使 ...
- Design Patterns Example Code (in C++)
Overview Design patterns are ways to reuse design solutions that other software developers have crea ...
- (转)MapReduce Design Patterns(chapter 1)(一)
翻译的是这本书: Chapter 1.Design Patterns and MapReduce MapReduce 是一种运行于成百上千台机器上的处理数据的框架,目前被google,Hadoop等多 ...
- How I explained Design Patterns to my wife: Part 1
Introduction Me and my wife had some interesting conversations on Object Oriented Design principles. ...
- Design Patterns Uncovered: The Chain Of Responsibility Pattern
Chain of Responsibility in the Real World The idea of the Chain Of Responsibility is that it avoids ...
- 图书-软件架构:《Design Patterns: Elements of Reusable Object-Oriented Software》(即后述《设计模式》一书)
ylbtech-图书-软件架构:<Design Patterns: Elements of Reusable Object-Oriented Software>(即后述<设计模式&g ...
- Design Patterns Simplified - Part 3 (Simple Factory)【设计模式简述--第三部分(简单工厂)】
原文链接:http://www.c-sharpcorner.com/UploadFile/19b1bd/design-patterns-simplified-part3-factory/ Design ...
- Design Patterns Simplified - Part 2 (Singleton)【设计模式简述--第二部分(单例模式)】
原文链接: http://www.c-sharpcorner.com/UploadFile/19b1bd/design-patterns-simplified-part-2-singleton/ De ...
- Head First Design Patterns
From Head First Design Patterns. Design Principle: Idnetify the aspects of your application that var ...
随机推荐
- 多态与异常处理ppt作业
1.请阅读并运行AboutException.java示例,然后通过后面的几页PPT了解Java中实现异常处理的基础知识. 答:1.抛出异常 当程序发生异常时,产生一个异常事件,生成一个异常对象,并把 ...
- 转:永久解决火狐浏览器出现的flash版本更新问题
发现问题: 1.找到火狐浏览器,并打开出现问题的页面. 2.点击火狐浏览器的"打开菜单"按钮,选择"附加组件"按钮. 3.在"搜索所有添加附件&quo ...
- 在 .NET 4.0 中使用 .NET 4.5 中新增的特性(CallerMemberNameAttribute/CallerFilePathAttribute/CallerLineNumberAttribute)
介绍 标题中所说的三个特性 CallerMemberNameAttribute / CallerFilePathAttribute / CallerLineNumberAttribute 我们统称为调 ...
- php+MySQL+Ajax
点赞功能原理. 图片. 1.connect.php文件 <?php $host="localhost"; $db_user="root"; $db ...
- 3.springMVC+spring+Mybatis整合Demo(单表的增删该查,这里主要是贴代码,不多解释了)
前面给大家讲了整合的思路和整合的过程,在这里就不在提了,直接把springMVC+spring+Mybatis整合的实例代码(单表的增删改查)贴给大家: 首先是目录结构: 仔细看看这个目录结构:我不详 ...
- c++ 二维数组传递
c++ 二维数组传递 我们在传递二维数组时,对于新手来说,可能会存在某些问题,下面讲解几种传递方法 在讲解如何传递二维数组时,先看看如何动态new 二维数组 // 二维数组动态申请 int row , ...
- <textarea>没有内容时,按回车键,设置光标不换行
$("textarea").val($("textarea").val().replace(/\n/g,""));
- Web 项目中分享到微博、QQ空间等分享功能
Web 项目中分享到微博.QQ空间等分享功能 网上有很多的模板以及代码,但是有很多都不能分享内容,简单的测试了下: 以新浪微博为例,文本框中的内容是title属性,下面的链接是url属性,如果你的链接 ...
- DeepLearning学习(1)--多层感知机
想直接学习卷积神经网络,结果发现因为神经网络的基础较弱,学习起来比较困难,所以准备一步步学.并记录下来,其中会有很多摘抄. (一)什么是多层感知器和反向传播 1,单个神经元 神经网络的基本单元就是神经 ...
- photoshop cs5 key
序列号: 1330-1164-2870-9234-4243-7879 1330-1027-8489-4513-0233-4890 1330-1176-2865-0373-1551-0175 1330- ...