编码原则 之 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,我需要专注的就是把业务逻辑写好.写业务逻辑并不复杂,就是把编程最基础的东西使用好,有变量.循环.流程控制.函数.数据库等. 但是写出的逻辑要通俗易懂.易于理解,避免炫技.晦 ...
随机推荐
- Druid连接池(二)
DRUID是阿里巴巴开源平台上一个数据库连接池实现,它结合了C3P0.DBCP.PROXOOL等DB池的优点,同时加入了日志监控,可以很好的监控DB池连接和SQL的执行情况,可以说是针对监控而生的DB ...
- java 中的 Comparable 和 Comparator 与 Iterable 和 Iterator
Comparable 和 Comparator Comparable 和 Comparator 是两个关系不大的类,其分别侧重于不同的方面. 其中,接口 Comparable<T> 强行对 ...
- arch 相关软件及脚本
安装 arch 脚本 sudo pacman -S arch-install-scripts 安装 ssh 并开启服务 sudo pacman -S open-ssh vim /etc/ssh/ss ...
- 1 主机WiFi连接下与虚拟机通信问题
环境: 主机:win10系统 虚拟机软件:VMware 虚拟机:winserver 2012 R2 datacenter (数据中心版) 网络上有很多方法说设置NAT模式,并不好用,主机如果用网线连接 ...
- luke下载使用
网上内容太多,下载了却不管用,即使下载了,也不知道怎么用.(对我这种小白来说,大神就一笑而过吧) 下载地址:http://www.xdowns.com/app/253909.html(如若下载不到可以 ...
- html 中a标签的问题(无反应,跳转,调用方法)
让超链接点击后不跳转,可以用href = "#",但是这个#就会锚点到页面最上边 点击链接后不跳转可以设置成 1.<a href="javascri ...
- 带你开发一款给Apk中自动注入代码工具icodetools(完善篇)【申明:来源于网络】
带你开发一款给Apk中自动注入代码工具icodetools(完善篇)[申明:来源于网络] 带你开发一款给Apk中自动注入代码工具icodetools(完善篇):http://blog.csdn.net ...
- Gym 101775B - Scapegoat - [贪心+优先队列]
题目链接:http://codeforces.com/gym/101775/problem/B Aori is very careless so she is always making troubl ...
- mysql新建数据库、新建用户及授权操作
1.创建数据库create database if not exists test176 default charset utf8 collate utf8_general_ci; #utf8_gen ...
- 在window 2008r2开发服务器上安装MSMQ消息队列
1.打开”服务器管理器“------”功能“-------”添加功能“,勾选”消息队列“,如下图: 如果之前已经勾选,则忽略此步. 2.”功能“------”消息队列“------”专有对列“---- ...