Bridge Pattern
and Marker Interface
Can any one explain,
Bridge Pattern as the name suggests is used maily to decouple
the interface and the class implementing the interface.
Marker Interfaces are interfaces in Java that have no
behavior. In other words, they are just empty interface definitions.
Pallav Then regarding marker interface, I have some basic understanding. All interfaces can act as marker interface but null interfaces are the most suited for it. also every interface has a boolean flag and that boolean flag goes for the entire generation of classes implenting that interface. I understand this boolean flag is the marker. What I want to know how this stuff is working in detail? Bharath Chinnadurai The following is for Marker Interface: Marker Interface
- java,lang.Cloneable
Marker interfaces are also called "tag" interfaces since they tag all the derived classes into a category based on their purpose. For example, all classes that implement the Cloneable interface can be cloned (i.e., the clone() method can be called on them). The Java compiler checks to make sure that if the clone() method is called on a class and the class implements the Cloneable interface. For example, consider the following call to the clone() method on an object o: SomeObject o = new SomeObject();
If the class SomeObject does not implement the interface Cloneable (and Cloneable is not implemented by any of the superclasses that SomeObject inherits from), the compiler will mark this line as an error. This is because the clone() method may only be called by objects of type "Cloneable." Hence, even though Cloneable is an empty interface, it serves an important purpose. Marker interfaces are simply interfaces which are blank
i.e. without any methods, fields.
Also you can very well override these methods in your class and provide an implementation which is specific to your need. Pallav
Related:
Java Certification, Programming, JavaBean and Object Oriented Reference Books Return to : Java Programming Hints and Tips All the site contents are Copyright © www.erpgreat.com
and the content authors. All rights reserved.
|