Imagine a class which wraps an external API or read large files or parses huge XML files, fetches data from the Internet or something else. There are thousands of situations like that.
In many cases, you can want to not parse/download/load some resources every time, right?. A good option is to use a cache but, to be honest, it’s difficult. In this article I’ll show you a simple and flexible solution.
Some time ago I got my friend’s code to review. Nothing special. After a few minutes of reading, I noticed that he added an empty interface to the definition of some classes. I was ready to write a comment about it but I heard a voice in my head to ask Google first.
I’ve discovered something interesting. A long time ago, when Java 1.5 was not yet released and annotations were not available in the language it was common to use something called “marker interface”. What is marker interface?