Design Patterns: Bridge (Handle/Body)

Posted by Monik, 29 October 2010.
Programming Code Design Design Patterns
Book summary
Summary on basis of the book ,,Design Patterns: Elements of Reusable Object-Oriented Software'', by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides, Addison-Wesley, 1995.

Class{
House house;
...
}
...
public static void main(String[] args){
Class c = new Class(new DetachedHouse());
}
Bridge pattern is when we use Interface/Absract class in a class instead of concrete subclasses, and instantiate it from outside, with concrete instance.

We use it to separate abstraction from its implementation. Actually we usually have a class hierarchy for imlementation (e.g. arrayList, static array), and separate class hierarchy for abstraction (FIFO, LIFO) - in this way we connect them.

Comments


Comments: