原文

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的更多相关文章

  1. 编码原则 之 Explicit Dependencies Principle

    Explicit Dependencies Principle The Explicit Dependencies Principle states: Methods and classes shou ...

  2. S.O.L.I.D 是面向对象设计(OOD)和面向对象编程(OOP)中的几个重要编码原则

    注:以下图片均来自<如何向妻子解释OOD>译文链接:http://www.cnblogs.com/niyw/archive/2011/01/25/1940603.html      < ...

  3. 设计模式-设计原则(Design Principle)

    本文由@呆代待殆原创,转载请注明出处. 写在前面:所谓设计原则并不是一定要遵守的法则,只是一种建议,因为保持这些原则本身会有一定代价,若是这些代价超过了带来的好处就得不偿失了,所以一切还是以简单为准. ...

  4. 命令查询分离原则Command-query separation principle

    在UML和模式应用一书中,发送给Die的roll消息之后跟随着第二个消息getFaceValue用于提取其新的faceValue,特别是:roll()方法是void的,没有返回值,例如: public ...

  5. 面象对象设计原则之一:单一职责原则(Single Responsibility Principle, SRP)

    单一职责原则是最简单的面向对象设计原则,它用于控制类的粒度大小.单一职责原则定义如下:单一职责原则(Single Responsibility Principle, SRP):一个类只负责一个功能领域 ...

  6. 里氏代换原则(Liskov Substitution Principle,LSP)

    第一种定义: 如果对每一个类型为S的对象o1,都有类型为T的对象o2,使得以T定义的所有程序P在所有的对象o1都代换为o2,程序P的行为没有发生变化,那么类型S是类型T的子类型. 第二种定义: 所有引 ...

  7. 编码原则实例------c++程序设计原理与实践(进阶篇)

    编码原则: 一般原则 预处理原则 命名和布局原则 类原则 函数和表达式原则 硬实时原则 关键系统原则 (硬实时原则.关键系统原则仅用于硬实时和关键系统程序设计) (严格原则都用一个大写字母R及其编号标 ...

  8. Web前端安全之安全编码原则

    随着Web和移动应用等的快速发展,越来越多的Web安全问题逐渐显示出来.一个网站或一个移动应用,如果没有做好相关的安全防范工作,不仅会造成用户信息.服务器或数据库信息的泄露,更可能会造成用户财产的损失 ...

  9. Python写业务逻辑的几个编码原则

    作为一个写业务逻辑的boy,我需要专注的就是把业务逻辑写好.写业务逻辑并不复杂,就是把编程最基础的东西使用好,有变量.循环.流程控制.函数.数据库等. 但是写出的逻辑要通俗易懂.易于理解,避免炫技.晦 ...

随机推荐

  1. mybatis07--关联查询一对多

    案例   查询国家的同时,查询出国家下的省会信息! 01.使用单表的连接查询 创建对应的实体类 和数据库表 /** * *国家的实体类 */ public class Country { privat ...

  2. 关于 telegram中 callback_data <= 64bytes 的解决方法

    解决方法: # bind data to uuid import uuid my_data = long_json_string my_uuid = uuid.uuid4() user_data[my ...

  3. html5与css 1. web标准及组成

    学习目标 1.本专业介绍.HTML相关概念,HTML发展历史 2.WEB标准,W3C/WHATWG/ECMA相关概念 3.相关软件的应用以及站点的创建 4.HTML基本结构和HTML语法 5.HTML ...

  4. 3 Oracle 32位客户端安装及arcgis连接

    关于Oracle服务器端安装及配置的过程详见第2篇文章,链接如下:http://www.cnblogs.com/gistrd/p/8494292.html,本篇介绍客户端安装配置及连接arcgis过程 ...

  5. elk-插件(head、X-pack)(五)

    一.修改ES配置,允许REST跨源操作ES服务器,添加以下2个配置,并重启ES. http.cors.enabled: true #如果启用了 HTTP 端口,那么此属性会指定是否允许跨源 REST ...

  6. (转)JVM中的OopMap(zz)

    原文地址: http://www.cnblogs.com/strinkbug/p/6376525.html 在读周智明的深入理解JVM虚拟机时,关于枚举根节点/安全点这部分感觉书上写的不是太明白,找了 ...

  7. js隐藏中间4位,变成‘*’号

    var tel = "15222622548"; var reg = /^(\d{3})\d{4}(\d{4})$/; tel = tel.replace(reg, "$ ...

  8. sql server中的charindex函数用法解析(在一段字符中搜索字符或者字符串-----返回expression1在expression2出现的位置;反之,返回0)

    https://blog.csdn.net/xinghuo0007/article/details/70651358 知识点一:charindex()语法 CHARINDEX ( expression ...

  9. laravel使用记录

    引用外部文件方式参考地址:https://blog.csdn.net/Darry_Zhao/article/details/52689635 跟踪数据库执行语句 DB::enableQueryLog( ...

  10. sourceTree回退撤销commit

    https://blog.csdn.net/gang544043963/article/details/71511958