I was making a swing application and realized that I have several classes that need access to the same set of constants. I could not bring myself to declare one of the main holders of them and place everyone there, and others would talk about it; I thought, hey, I just all inherit from some common place, but Java does not do multiple inheritance, BUT I can put infinite interfaces on things. So, an idea came to me to dump them all into an interface (it's true, this is just a natural event for me, without doing any research).
Later I found out that it was heresy. "In fact, such a bad idea that there is a name for it:" Antipattern Permanent Interface "- as discussed here (along with an alternative solution (which I chose to use)).
I was fine with this until I looked at the source code for JDialog and JFrame , which reads as follows:
public class JDialog extends Dialog implements WindowConstants, Accessible, RootPaneContainer, TransferHandler.HasGetTransferHandler { ...
and
public class JFrame extends Frame implements WindowConstants, Accessible, RootPaneContainer, TransferHandler.HasGetTransferHandler { ...
Maybe it's just me, but I'm sure there is a consistent interface there. Even more interesting was one of the author's declarations in JDialog, i.e. James Gosling Did the tongue father make this supposed mistake on his watch?
(Another famous example is SwingConstans )
If a persistent antipattern interface is such a bad idea, then why is it so heavily used in one of the most famous language packages (i.e. swing)?