编码原则 之 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

转载于:https://www.cnblogs.com/panpanwelcome/p/10195338.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值