Referring to the below link:
http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html?page=2
The composition approach to code reuse pro
Well, in the composition case, Apple.peel()
's implementation needs to be updated, but its method signature can stay the same. And that means the client code (which uses Apple
) does not have to be modified, retested, and redeployed.
This is in contrast to inheritance, where a change in Fruit.peel()
's method signature would require changes all way into the client code.