Bridge Design Pattern

Bridge is a structural design pattern that allows you to divide a large class or a set of closely related classes into two separate hierarchies (abstraction and implementation) that can be developed independently of each other.

Bridge is a synonym for the expression “handle / body”. This is a design mechanism that encapsulates an implementation class within an interface class. The first is the body and the second is the handle. The user sees the identifier as the actual class, but the work is done in the body. “The idiom for the handle / body class can be used to decompose a complex abstraction into smaller, more manageable classes. The idiom can reflect the sharing of a single resource by multiple classes that control access to it (for example, the count of references)”.

  • Decouple an abstraction from your implementation so that the two can vary independently.
  • Publish the interface in an inheritance hierarchy and hide the implementation in its own inheritance hierarchy.

Lets take a look at the code samples I created as below.

PHP Code Sample

C# Code Sample

By Yuuma.




tel. 06-6454-8833(平日 10:00~17:00)