Composition, I don't quite get this?

后端 未结 5 993
面向向阳花
面向向阳花 2021-01-21 04:27

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

5条回答
  •  遥遥无期
    2021-01-21 04:56

    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.

提交回复
热议问题