I have read the Bridge pattern from the GoF book . Now trying to map the patterns to core java libraries but having a difficult time finding an example of the Bridge pattern . What is a example of Bridge pattern in the core java library where there is clean separation between an abstraction and its implementation?
-
I used the Bridge pattern exactly once, in 1997, and I've regretted it ever since. – user207421 Feb 15 '13 at 09:45
-
1Related: http://stackoverflow.com/questions/1673841/examples-of-gof-design-patterns/ – BalusC Jun 30 '13 at 02:58
2 Answers
(a) the JDBC API (a set of interfaces such as DataSource, PooledConnection, RowSet etc.) is typically considered as a bridge, which allows independent implementations for different databases (such as Sybase, Oracle or other ODBC databases) http://docstore.mik.ua/orelly/java-ent/servlet/ch09_02.htm;
(b) SLF4J, as hinted by its name (the Simple Logging Facade for Java), serves more as a facade than a bridge since you can still use java.util.logging, logback, log4j without SLF4J (but this is not the case for a bridge: an ODBC database can't be accessed directly without going through the JDBC interfaces);

- 241
- 3
- 7
Here is an article that says A Classic Example of Bridge is Drivers
- http://www.informit.com/articles/article.aspx?p=29302.
And for me, classic examples of bridge (though it's not core Java) are JCL and SLF4J.

- 133,369
- 30
- 199
- 275