Q-1). What is the intent of the Bridge Design Pattern?

A-1). To decouple an abstraction from its implementation so that both can vary independently.

Q-2). What are the participants in the Bridge Pattern?

A-2). The participants in the Bridge Design Pattern are as follows:

  • Abstraction
  • Refined Abstraction
  • Implementor
  • Concrete Implementor

Q-3). How is the Bridge Pattern different from the Adapter Pattern?

A-3). The differences between the Bridge Design Pattern and the Adapter Design Pattern are as follows:

Bridge Design PatternAdapter Design Pattern
Bridge decouples abstraction and implementation from the start.The Adapter allows existing incompatible interfaces to work together.
The Bridge is for design-time flexibility.The Adapter is for retrofit-time compatibility.

Q-4). How does the Bridge Pattern support the Open/Closed Principle?

A-4). You can add new abstractions or implementations without modifying existing classes, thus making the system open for extension and closed for modification.

Q-5). Give a real-world example of when using the Bridge Pattern could reduce technical debt?

A-5). In a payment processing system where you have multiple payment gateways (Stripe, PayPal) and multiple payment types (Subscription, One-time), using Bridge allows you to add new gateways or payment types independently, instead of creating a complex inheritance matrix like StripeSubscription, StripeOneTime, PayPalSubscription, etc.