Adam Bien's Weblog

Searching For Suspicious (Superfluous) Interfaces With IntelliJ

In enterprise apps interfaces are at least suspicious in case:

  1. There is and very likely will be a 1:1 relation between the interface and its realization through the whole application lifecycle
  2. You cannot name an interface properly any more and are forced to use naming conventions like "Impl" or "I" to avoid name clashes

IntelliJ comes with structural search. "Structural Search" is a (Groovy/Java) programmable search facility with that you can easily find all (probably superfluous) interfaces with only a single implementation:

  1. Go to: Search -> Search Structurally
  2. Push: Copy Existing Template -> class-based -> interface that is not implemented or extended
  3. Push: "Edit Variables" and replace the content of the "Script Text" with == 1

The found interfaces are probably superfluous if you cannot clearly explain their intentions/purpose (decoupling, extensibility etc. is not good enough for a justification).
[Warning: this script is not perfect: it will also find cases of interface inheritance.]

NEW workshop: Building HTML 5 Applications With Angular 2
Full week in December 2016: from Java EE 7 Bootstrap, Effective, Architectures over Testing to Microservices
On demand workshops: Java EE 7: Bootstrap, Effective, Testing and Microservices available for streaming.


A book about rethinking Java EE Patterns


Unless you're implementing a framework/library

Posted by Pascal Bleser on August 02, 2011 at 04:29 PM CEST #


+1 and -1 :-).

If you design an API let's say JDBC, it is a good idea to use interfaces or abstract classes for this purpose.

But: if there is only a single implementation of the API (a SPI -> e.g. only a MySQL implementation), I would question the added value of such an API.

thanks for your feedback!,


Posted by Adam Bien on August 02, 2011 at 05:06 PM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
...the last 150 posts
...the last 10 comments