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?
(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);
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With