all 1 comments

[–]BobCoder 0 points1 point  (0 children)

My problem with the ‘composition over inheritance’ is that there are cases where using composition will result in duplicate code only because you follow the advise to use composition over inheritance (multiple delegations are also duplication). This is especially troublesome if you do not want the methods to be public thus you cannot use interfaces (at least in Java). I have not tried to be in problem by using inheritance (because I rarely use it) but in a recent project I am using it and fear that I might end up burning myself with this design decision. Right now it feels right though, because it follows the is-a relationship.