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、 使用多重继承分离接口

                                                                                                                                                      原文作者   吕震宇

  • 相关阅读:
    第一章 操作系统引论
    程序流程结构
    IE网页cab插件无法安装
    Java面试题整理(题目内容非原创)
    linux下安装字体
    博客园使用Silence主题装饰
    编码问题总结
    JUnit 4.10 新功能简介——RuleChain 和TemporaryFolder的应用
    Usage and Idioms——Rules
    Usage and Idioms——Theories
  • 原文地址:https://www.cnblogs.com/EasyLive2006/p/658903.html
Copyright © 2011-2022 走看看