I'm working with a Java project that has several interfaces, many of which have only one implementation. (See related question)

For a given revision of the software, one could think this acceptable because the interfaces were some plan for future extensions. However, when I look at the 200+ revisions over several years, those interfaces never had more than one implementation, (nor were they used in unit-testing).

It seems that in these cases of probable bloat (YAGNI) owing to the Interface Anti-pattern, it would be useful to apply the inverse of Extract Interface. However, Inline Class (the supposed inverse according to refactoring.com) is not what I'm referring to.

What's the name of the refactoring that removes an unused interface, substituting the sole class that implements it?

  • Merge interface (on the expectation that the class has at least some other members)? – david.pfx Mar 22 '14 at 14:09
  • I found this blog that speaks of Merge Interface and Implementation (and it's spot-on to the gist of my question). It also states that no popular IDEs offer this refactoring, which also kind of answers my question at the same time. @david.pfx I recommend you submit your remark as an answer. – Fuhrmanator Mar 22 '14 at 17:22

Merge Interface (on the expectation that the class has at least some other members)?

As suggested, Merge Interface and Implementation would be even more descriptive. I don't recall ever seeing it in an IDE.

  • Resharper (and probably all JetBrains IDEs) have 'Safe Delete' which lets you replace usages with an implementation. – mcintyre321 Jan 16 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.