Systematically refactoring inheritance to delegation in java

Hannes Kegel, Friedrich Steimann
2008 Proceedings of the 13th international conference on Software engineering - ICSE '08  
Because of the strong coupling of classes and the proliferation of unneeded class members induced by inheritance, the suggestion to use composition and delegation instead has become commonplace. The presentation of a corresponding refactoring in the literature may lead one to believe that such a transformation is a straightforward undertaking. However, closer analysis reveals that this refactoring is neither always possible, nor does it necessarily achieve its desired effect. We have therefore
more » ... dentified the necessary preconditions and realizable postconditions of the refactoring, and built a tool that can perform it completely automatically. By applying this tool to all subclasses of several open-source projects, we have collected evidence of the applicability of the refactoring and of its capability to deliver on its promises. The refactoring builds on constraint graphs originally developed for type inference to check the preconditions and to compute the necessary delegation as well as the subtype relationships that must be maintained.
doi:10.1145/1368088.1368147 dblp:conf/icse/KegelS08 fatcat:zhmeg2ykivbbzjqbp447caakey