zoukankan      html  css  js  c++  java
  • 接口隔离原则(ISP)

    接口隔离原则(ISP)

    接口隔离原则(Interface Segregation Principle)讲的是:使用多个专门的接口比使用单一的总接口总要好。换而言之,从一个客户类的角度来讲:一个类对另外一个类的依赖性应当是建立在最小接口上的。

    过于臃肿的接口是对接口的污染。不应该强迫客户依赖于它们不用的方法。

    My object-oriented umbrella(摘自Design Patterns Explained)

    Let me tell you about my great umbrella. It is large enough to get into! In fact, three or four other people can get in it with me. While we are in it, staying out of the rain, I can move it from one place to another. It has a stereo system to keep me entertained while I stay dry. Amazingly enough, it can also condition the air to make it warmer or colder. It is one cool umbrella.

    My umbrella is convenient. It sits there waiting for me. It has wheels on it so that I do not have to carry it around. I don't even have to push it because it can propel itself. Sometimes, I will open the top of my umbrella to let in the sun. (Why I am using my umbrella when it is sunny outside is beyond me!)

    In Seattle, there are hundreds of thousands of these umbrellas in all kinds of colors. Most people call them cars.

    实现方法:
    1、 使用委托分离接口
    2、 使用多重继承分离接口

                                                                                                                                                      原文作者   吕震宇

  • 相关阅读:
    Microsoft Web Camp
    [程序员学英语]26个英文字母
    原来接口是这样用的!一个例子搞定接口
    BizTalk Server 2010 培训
    [PM Tools]软件项目进度跟踪表v4.0
    BizTalk 开发系列(四十一) BizTalk 2010 BAM 安装手记
    WCF服务编程HelloWorld
    BizTalk 开发系列(三十九) BizTalk Server 2009技术概览
    WCF服务编程WCF应用程序的消息跟踪
    WCF服务编程基础
  • 原文地址:https://www.cnblogs.com/EasyLive2006/p/658903.html
Copyright © 2011-2022 走看看