Geek
Geek

Reputation: 27173

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?

Upvotes: 7

Views: 2715

Answers (2)

user3044236
user3044236

Reputation: 251

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

Upvotes: 6

Evgeniy Dorofeev
Evgeniy Dorofeev

Reputation: 135992

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.

Upvotes: 5

Related Questions