Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is an example of the Bridge Pattern in core Java?

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?

like image 523
Geek Avatar asked Feb 15 '13 04:02

Geek


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);

like image 183
user3044236 Avatar answered Nov 15 '22 00:11

user3044236


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.

like image 41
Evgeniy Dorofeev Avatar answered Nov 14 '22 23:11

Evgeniy Dorofeev