菜单
  

     
    Fig. 4 Pure Substitution
    That is, the base class can receive any message you can send to the derived class because the two have exactly the same interface. All you need to do is upcast from the derived class and never look back to see what exact type of object you’re dealing with. Everything is handled through polymorphism.
    When you see it this way, it seems like a pure is-a relationship is the only sensible way to do things, and any other design indicates muddled thinking and is by definition broken. This too is a trap. As soon as you start thinking this way, you’ll turn around and discover that extending the interface (which, unfortunately, the keyword extends seems to encourage) is the perfect solution to a particular problem. This could be termed an “is-like-a” relationship, because the derived class is like the base class—it has the same fundamental interface—but it has other features that require additional methods to implement:
     
    Fig. 5 Implement Interface
    While this is also a useful and sensible approach (depending on the situation), it has a drawback. The extended part of the interface in the derived class is not available from the base class, so once you upcast, you can’t call the new methods:
     
    Fig. 6 Deliver Message
    If you’re not upcasting in this case, it won’t bother you, but often you’ll get into a situation in which you need to rediscover the exact type of the object so you can access the extended methods of that type. The following section shows how this is done.
    B.原文的翻译
    多形性对于一个面向对象的语言来说,是继数据的抽象化和继承之后最为重要的特点。论文网
    它提供了另一种方式去分离本来用户想用与继承的接口,而且它让从什么到怎么的过程中更加的低耦合,多形性允许改善代码的组织性和稳定性,就好像让一个可扩展的程序变得拥有了成长性,而且这种的成长性的产生不仅仅使用与程序的开头,当新的特征出现的之后它也是可以实现这种功能的。
  1. 上一篇:电子商务英文文献和中文翻译
  2. 下一篇:搅拌釜内混合液体的分离涡模拟英文文献和中文翻译
  1. JSP英文文献和中文翻译

  2. Java技术的Web应用设计模型...

  3. ASP.NET技术先进的控件编程...

  4. 电气系统的可编程序控制...

  5. PLC可编程逻辑控制器英文文献和中文翻译

  6. JAVA和因特网英文文献及中文翻译

  7. java对象的介绍英文文献和中文翻译

  8. java+mysql车辆管理系统的设计+源代码

  9. 乳业同业并购式全产业链...

  10. 电站锅炉暖风器设计任务书

  11. 酸性水汽提装置总汽提塔设计+CAD图纸

  12. 杂拟谷盗体内共生菌沃尔...

  13. 当代大学生慈善意识研究+文献综述

  14. 十二层带中心支撑钢结构...

  15. 河岸冲刷和泥沙淤积的监测国内外研究现状

  16. 中考体育项目与体育教学合理结合的研究

  17. 大众媒体对公共政策制定的影响

  

About

751论文网手机版...

主页:http://www.751com.cn

关闭返回