With all the recent news about Facebook's data being leveraged by Cambridge Analytica for political persuasion I felt it a good time to resurface this story from about 4 years ago. If you are unfamiliar with some of the targeting methods in Facebook it's both a funny and insightful read.
And interfaces can have default methods. And that means that enums with a similar use can avoid copy-pasting code, by implementing the appropriate interface.
I love enums. They're a great tool for ensuring something exists exactly once, but maybe it has a few brothers and sisters.
What I hate about enums is that Java refuses to let us subclass them, and refuses to let us inherit from a class of our own choice, because it already inherits from a class by design, and Java refuses to allow multiple inheritance.
The pain is great and has led to duplicate code in my past.
Until today. Because today I learned from people on StackOverflow that enums can implement interfaces.
I should have realized that years ago. But I'm happy to know it now, and I hope some of you will be helped by this, as well.