Notes on ‘Refactoring ‘ — 6.1 Replace Inheritance with Delegation

When?

  You find that some of the superclass operations aren’t really true of the subclass. The code is saying the subclass has some interface that it doesn’t have. This is confusing.

How to solve it?

  1. The subclass doesn’t extend its superclass anymore

  2. Instead, subclass should REFERENCE superclass to use it as a delegate

 

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.