The idea or purpose of the marker interface sounds totally meaningless to me.
While searching for the "Serializable Class" in Java, I inevitably came to this concept, 'Marker Interface'. I understood why and when to use it - to tag/mark the class that it is for special usage, like serialization.
But the biggest point here is that the reason itself, I mean idea of marking the class to indicate that we'll use it for some usage but WITHOUT any method, seems quite a nonsense to me.
If we want to endow a class some special meanings so that it can perform the jobs we aim to, I strongly believe that it should contain methods written for that jobs. If it contains nothing inside, that what makes it different from the plain class? I can even put "implements Serializable" to any classes not intended to serialize..
To summarize- What's the GOOD of the Marker Interface?
Aucun commentaire:
Enregistrer un commentaire