Marker interface pattern: Difference between revisions

Content deleted Content added
No edit summary
Line 9:
== Critique ==
 
A major problem with marker interfaces is that an interface defines a contract for implementing classes, and that contract is inherited by all subclasses. This means that you cannot "unimplement" a marker. In the example given, if you create a subclass that you do not want to serialize (perhaps because it depends on transient state), you must resort to explicitly throwing <code>NotSerializableException</code> (per <code>ObjectOutputStream</code> docs).
 
Another solution is for the language to support [[metadata]] directly: