编码原则 之 Hollywood Principle
The Hollywood Principle states, “Don’t Call Us, We’ll Call You.”
It’s closely related to the Dependency Inversion Principle,
and illustrates a different way of writing software from the more traditional form of programming in which one’s own code dictates the flow of control. When following the Hollywood Principle, code is written to respond to external events, such as from an existing framework.
By way of an example,
a typical ASP.NET Web Form might have in its code behind page event handlers to respond to Page_Load and Button_Click events.
An ASP.NET developer writes code to respond to these external framework events, instead of owning the execution of the web server and making all decisions and method calls accordingly.
Plug-in and extension models for applications frequently must take advantage of the Hollywood Principle in their design,
exposing events and similar “hooks” for plug-in modules to use,allowing the overall program to call into the plug-in whenever needed, while avoiding the having the plug-in code take over control of the execution of the entire application.
See Also
Dependency Inversion Principle
References
Inversion of Control by Martin Fowler
2013 Software Craftsmanship Calendar
编码原则 之 Hollywood Principle的更多相关文章
- 编码原则 之 Explicit Dependencies Principle
Explicit Dependencies Principle The Explicit Dependencies Principle states: Methods and classes shou ...
- S.O.L.I.D 是面向对象设计(OOD)和面向对象编程(OOP)中的几个重要编码原则
注:以下图片均来自<如何向妻子解释OOD>译文链接:http://www.cnblogs.com/niyw/archive/2011/01/25/1940603.html < ...
- 设计模式-设计原则(Design Principle)
本文由@呆代待殆原创,转载请注明出处. 写在前面:所谓设计原则并不是一定要遵守的法则,只是一种建议,因为保持这些原则本身会有一定代价,若是这些代价超过了带来的好处就得不偿失了,所以一切还是以简单为准. ...
- 命令查询分离原则Command-query separation principle
在UML和模式应用一书中,发送给Die的roll消息之后跟随着第二个消息getFaceValue用于提取其新的faceValue,特别是:roll()方法是void的,没有返回值,例如: public ...
- 面象对象设计原则之一:单一职责原则(Single Responsibility Principle, SRP)
单一职责原则是最简单的面向对象设计原则,它用于控制类的粒度大小.单一职责原则定义如下:单一职责原则(Single Responsibility Principle, SRP):一个类只负责一个功能领域 ...
- 里氏代换原则(Liskov Substitution Principle,LSP)
第一种定义: 如果对每一个类型为S的对象o1,都有类型为T的对象o2,使得以T定义的所有程序P在所有的对象o1都代换为o2,程序P的行为没有发生变化,那么类型S是类型T的子类型. 第二种定义: 所有引 ...
- 编码原则实例------c++程序设计原理与实践(进阶篇)
编码原则: 一般原则 预处理原则 命名和布局原则 类原则 函数和表达式原则 硬实时原则 关键系统原则 (硬实时原则.关键系统原则仅用于硬实时和关键系统程序设计) (严格原则都用一个大写字母R及其编号标 ...
- Web前端安全之安全编码原则
随着Web和移动应用等的快速发展,越来越多的Web安全问题逐渐显示出来.一个网站或一个移动应用,如果没有做好相关的安全防范工作,不仅会造成用户信息.服务器或数据库信息的泄露,更可能会造成用户财产的损失 ...
- Python写业务逻辑的几个编码原则
作为一个写业务逻辑的boy,我需要专注的就是把业务逻辑写好.写业务逻辑并不复杂,就是把编程最基础的东西使用好,有变量.循环.流程控制.函数.数据库等. 但是写出的逻辑要通俗易懂.易于理解,避免炫技.晦 ...
随机推荐
- git 回滚指定行
Stage the parts you want with git add -p, then discard (git checkout -- filename) the unstaged chang ...
- C# word 图片大小
通过Office自带的类库word文档中插入图片,图片大小的单位为磅 而文档中,图片的大小已经固定,为CM. 实际工作中,首先将图片插入到word中,根据目前的大小,计算转换为目标大小的比率,将长宽按 ...
- 选择结构的三角关系Switch、Case、Default!!!
选择结构的三角关系Switch.Case.Default!!! 今天我们学习选择结构进化章节——Switch结构,他与if有什么区别呢? 相同点: 都是用来处理多分支条件的结构 不同点: switch ...
- vim-cscope插件
在工程根目录生成cscope.out 索引文件的脚本 rm -f cscope* currentPath=$(pwd ) echo $currentPath find $currentPath -na ...
- Win7 搭建Linux开发环境
Vargant Vagrant 是一个基于 Ruby 的工具,用于创建和部署虚拟化开发环境.它使用 Oracle 的开源 VirtualBox 虚拟化系统,使用 Chef 创建自动化虚拟环境. 功能特 ...
- Java ee第七周作业
一.什么是JSON?JSON是一种取代XML的数据结构,和xml相比,它更小巧但描述能力却不差,由于它的小巧所以网络传输数据将减少更多流量从而加快速度. JSON就是一串字符串 只不过元素会使用特定的 ...
- 如何生成Junit报告
前言: 对Eclipse的工程写单元测试: 1. 一个工程有多个测试类,将测试类放到一个测试包下. 2. 每一个测试类写好,都单独执行run as ->JUnit Test测一下. 3. ...
- ARGB与RGB、RGBA的区别
ARGB 是一种色彩模式,也就是RGB色彩模式附加上Alpha(透明度)通道,常见于32位位图的存储结构. RGB 色彩模式是工业界的一种颜色标准,是通过对红(R).绿(G).蓝(B)三个颜色通道的变 ...
- linux环境如何配置repo
(1)下载repo mkdir ~/bin curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo ...
- pytorch torchvision对图像进行变换
class torchvision.transforms.Compose(转换) 多个将transform组合起来使用. class torchvision.transforms.CenterCrop ...