O'Reilly logo

C# 3.0 Design Patterns by Judith Bishop

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Bridge Pattern

Role

The Bridge pattern decouples an abstraction from its implementation, enabling them to vary independently. The Bridge pattern is useful when a new version of software is brought out that will replace an existing version, but the older version must still run for its existing client base. The client code will not have to change, as it is conforming to a given abstraction, but the client will need to indicate which version it wants to use.

Illustration

Consider the rolling out of a new version of the .NET Framework used to compile and run C# 3.0. You can have several versions of the Framework loaded on your computer at any time and can select which one to use by externally setting a path to it in the Windows operating system. Setting the path is the bridge between what applications want from the Framework and the actual version they will get. In Figure 2-6, you can see that there are five versions of the Framework loaded on my computer. Figure 2-7 shows that the one the system is being directed to is Version 3.5, which includes the C# 3.0 compiler.

Bridge pattern illustration (a)—environment Path variable set to Version 3.5

Figure 2-6. Bridge pattern illustration (a)—environment Path variable set to Version 3.5

Bridge pattern illustration (b)—five versions of the .NET Framework loaded

Figure 2-7. Bridge pattern illustration (b)—five versions of the .NET Framework loaded

Design

Inheritance is a common way to specify different ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required