Asks the candidate to enumerate design patterns they have personally implemented in production, explaining the problem context, why the pattern was chosen, and the trade-offs involved. The discussion frequently drills into the Bridge pattern.
Bridge Pattern Deep-Dive
The Bridge pattern decouples an abstraction from its implementation so the two can vary independently.
- Motivation: Avoid a Cartesian explosion of subclasses when there are two orthogonal dimensions of variation (e.g., shapes × rendering engines, devices × remote controls).
- Structure: An
Abstraction holds a reference to an Implementor interface. Concrete abstractions and concrete implementors evolve independently.
- vs. Adapter: Bridge is designed up-front; Adapter is a retrofit. Bridge separates concerns proactively.
- vs. Strategy: Strategy varies behavior/algorithm; Bridge varies the implementation platform/backend while keeping a stable abstraction hierarchy.
- Real-world examples: JDBC driver architecture, GUI toolkits (AWT), platform-independent rendering pipelines.
Common Follow-Ups
- Draw the class diagram for the Bridge pattern.
- When would you prefer Bridge over inheritance?
- How does Bridge relate to dependency injection?
- What are the downsides (indirection, added complexity for simple cases)?