编码原则 之 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,我需要专注的就是把业务逻辑写好.写业务逻辑并不复杂,就是把编程最基础的东西使用好,有变量.循环.流程控制.函数.数据库等. 但是写出的逻辑要通俗易懂.易于理解,避免炫技.晦 ...
随机推荐
- 腾讯地图key秘钥
腾讯地图key:5WNBZ-2JYR6-SPUSL-M3WGH-U4KDT-K2FYV
- python中print(obj) 与sys.stdout.write()的区别
print(obj) 其实等价于sys.stdout.write(obj+\n),而\r表示回到行首,所以需要输出进度条时可以用以下代码 rate = float(has_sent) / float( ...
- 向comboboxEdit中动态添加数据库中保存的用户自定义单位制的名称
if (radioGroup1.SelectedIndex == 2) { bool _Flag = true; sm.SetLciVisible(lciDelete, _Flag); sm.SetL ...
- Python学习之旅(二十五)
Python基础知识(24):正则表达式 正则表达式:检查一个字符串是否与某个模式匹配 \d :匹配数字 \w :匹配字母或数字 . :匹配任意字符 {n} :匹配n个字符 {m,n} :匹配m到n个 ...
- 利用excel模板,将数据填充到excel中
package com.excel;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundExce ...
- 转CB大佬的几个有用的MySQL知识
1.find_in_set函数 find_in_set(str,strlist); str是一个字符串 strlist是字符串列表--一个有多个子链被“,”分开的字符串 有多种情况: a.str为nu ...
- python语法_使用占位符进行格式化输出
“%s” 占位符 name = input("name:") age = input("age:") job = input("job:" ...
- Spring事物管理--相关要点及配置事物管理器
事务的四大特征 1.原子性:一个事务中所有对数据库的操作是一个不可分割的操作序列,要么全做要么全不做 2.一致性:数据不会因为事务的执行而遭到破坏 3.隔离性:一个事物的执行,不受其他事务的干扰,即并 ...
- static final 内部类
1 static关键字 1.1 static关键字概述类中的属性和方法都是通过创建本类对象调用的,当在调用对象的某个方法时,这个方法没有访问到对象的特有数据时,方法创建这个对象有些多余,可是不创建对象 ...
- 自动化安装-【kickstart】
批量自动安装软件介绍 kickstart 是一种无人值守的安装方式,工作原理是在安装过程中记录人工干预填写的各种参数,并生成以个名为ks.cfg(自动应答文件)的文件,如果在自动安装过程中出现要填写参 ...