Re: Programming to an Interface



On 2006-05-15 08:42:00 -0500, contravariance@xxxxxxxx said:

I never ever use the abstract keyword in Java and I never use
implementation inheritance either (note that Java's creator
emitted regrets not having gone "pure interface" [sic]). This at
least shows that it's possible to completely bypass implementation
inheritance when programming in Java.

Yes, it's possible to avoid using abstract; and without multiple inheritance there is considerable reason to avoid abstract. But I still use it. Every so often I get into a jam where I wish I could multilply inherit, or pull all my methods up to an interface. But these events are rare, and manageable. For the most part, abstract classes are very useful beasts.
--
Robert C. Martin (Uncle Bob)  | email: unclebob@xxxxxxxxxxxxxxxx
Object Mentor Inc.            | blog:  www.butunclebob.com
The Agile Transition Experts  | web:   www.objectmentor.com
800-338-6716                  |



.



Relevant Pages

  • Re: To understand OOP better...
    ... >>should avoid implementation inheritance of behaviors whenever possible. ... The issue here is not whether implementation inheritance and overrides ... instantiates the correct relationship to a specific leaf subclass ...
    (comp.object)
  • Re: To pull up or not
    ... Having identical pieces of code in multiple classes often leads over time to classes with *nearly* identical pieces of code, ... What bothers me most about implementation inheritance in Java is that there is no private inheritance, so there is no clear way to distinguish implementation inheritance from interface inheritance. ... IOW, if you have multiple classes inheriting from ObjectThatDoesX for implementation reasons, it may be tempting to start handling the subclasses using references of type ObjectThatDoesX. ...
    (comp.lang.java.programmer)
  • Re: Programming to an Interface
    ... implementation inheritance either. ... inheritance when programming in Java. ... implementation inheritance a single time). ... Consider this an invitation to use Python or some other dynamic language ...
    (comp.object)
  • Re: Programming to an Interface
    ... implementation inheritance either. ... inheritance when programming in Java. ... you would refuse to ever inherit if programming in Python, Ruby, ... implementation inheritance a single time). ...
    (comp.object)
  • Re: behavioral and implementation inheritance
    ... Behavioral inheritance is like ... inheriting interfaces or header ... Implementation inheritance is, well, inheriting ... implementation (*.cpp files in C++ terms) ...
    (comp.programming)