Question

Can someone give an example of Meyers Implementation inheritance in Java, the book in the link is about eiffel, but i need a java example.

I know java doesn't support multiple inheritance, so can we call it implementation inheritance if I implement an interface and extend a class?

Also does it have to have two parents to be a case of implementation inheritance?

Was it helpful?

Solution

The definitions from the book go over this here:

Definition: implementation inheritance Structural inheritance applies if B obtains from A a set of features (other than constant attributes and once functions) necessary to the implementation of the abstraction associated with B. Both A and B must be effective.

The classes A and B must not be deferred. That is the case when extending a non-abstract Java class A by a non-abstract class B.

Definition: reification inheritance Reification inheritance applies if A represents a general kind of data structures, and B represents a partial or complete choice of implementation for that data structure. A is deferred; B may still be deferred, leaving room for further reification through its own heirs, or it may be effective.

The class A is deferred, so this would be the case when implementing a Java interface A or extending a Java interface A (the new interface would then be B)

The case you specify (implementing an interface and extending a non-abstract class in Java) is a combination of these two. The text makes it quite clear here:

A common case is what will be called the "marriage of convenience", based on multiple inheritance, where one parent provides the specification (reification inheritance) and the other the implementation (implementation inheritance).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top