Incomplete Library Class


Symptoms

  • You're using a library class, and there's a feature you wish were on that class, but it's not. If it were a normal class, you'd modify it; but, since it is part of a library, you may be unable or unwilling to change it.

Causes

The author of the library class didn't anticipate your need (or declined to support it due to other trade-offs).

What to Do

  • See if the owner of the class or library will consider adding the support you want.

  • If it's just one or two methods , Introduce Foreign Method on a client of the library class. (This is still Feature Envy, but what can you do?)

  • If you have several methods, Introduce Local Extension (subclassing the library class to create a new pseudolibrary class). Use the new extension class going forward.

  • You may decide to introduce a layer covering the library.

Payoff

Reduces duplication (when you can reuse library code instead of implementing it completely from scratch).

Contraindications

If several projects each use incompatible ways to extend a library, this can lead to extra work if the library changes.



Refactoring Workbook
Refactoring Workbook
ISBN: 0321109295
EAN: 2147483647
Year: 2003
Pages: 146

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net