Home > Articles > Software Development & Management

Design Patterns Explained: The Bridge Pattern

  • PrintPrint
  • Share ThisShare This
  • DiscussDiscuss
Close Window

Alan ShallowayJames R. Trott

Learn more…

Sorry, this author hasn't written any articles.

Sorry, this author doesn't have anything for sale.

Sorry, this author hasn't posted any blogs.

This chapter discusses the Bridge pattern, including an example to help you derive the Bridge pattern, key features of the pattern, and observations on the Bridge pattern from the authors' own practice.

Overview

This chapter continues the discussion of design patterns with the Bridge pattern. The Bridge pattern is quite a bit more complex than the other patterns you have learned. It is also much more useful.

This chapter

  • Provides an example to help you derive the Bridge pattern. I go into great detail to help you learn this pattern.
  • Presents the key features of the pattern.
  • Presents some observations on the Bridge pattern from my own practice.

Introducing the Bridge Pattern

According to the Gang of Four, the intent of the Bridge pattern is to “decouple an abstraction from its implementation so that the two can vary independently.”1

I remember exactly what my first thoughts were when I read this: Huh?

And then: How come I understand every word in this sentence, but I have no idea what it means?

I knew that

  • Decouple means to have things behave independently from each other or at least explicitly state what the relationship is.
  • Abstraction is how different things are related to each other conceptually.

And I thought that implementations were the way to build the abstractions; but I was confused about how I was supposed to separate abstractions from the specific ways that implemented them.

It turns out that much of my confusion was due to misunderstanding what implementations meant. Implementations here means the objects that the abstract class and its derivations use to implement themselves (not the derivations of the abstract class, which are called concrete classes). To be honest, even if I had understood it properly, I am not sure how much it would have helped. The concept expressed in this sentence is just hard to understand at first.

If you are also confused about the Bridge pattern at this point, that is okay. If you understand the stated intent, you are that much ahead.

It is a challenging pattern to learn because it is so powerful.

The Bridge pattern is one of the toughest patterns to understand in part because it is so powerful and applies to so many situations. It also goes against a common tendency to handle special cases with inheritance. However, it is also an excellent example of following two of the mandates of the design pattern community: “Find what varies and encapsulate it” and “Favor aggregation over class inheritance” (as you will see).

  • Share ThisShare This
  • Your Account

Discussions

Make a New Comment

You must log in in order to post a comment.

Related Resources

Stephen MorrisGetting off the ground with your first iPhone app
By Stephen B. Morris on January 13, 20102 Comments

My first iPhone app – “The Day Was…” has now been through two updates. I want to talk a little about how to get started with this interesting technology. As with any software, the first step is having an idea, i.e., one or more requirements.

You Can Check Out Any Time You Like, But You Can Never Leave
By John Traenkenschuh on December 8, 2009 No Comments

Much like the line from the song, "Hotel California", Traenk finds out that membership with key Internet II sites is eternal...

Predictions and Predilections
By John Traenkenschuh on November 23, 2009 No Comments

Leaves are down; harvest is in, for the most part.  Another year comes rushing up to us.  What will it bring?

See All Related Blogs

Informit Network