What is the Bridge pattern and how does it decouple abstraction from implementation?

The Bridge pattern is a structural pattern that separates a high-level abstraction from its low-level implementation by connecting them through composition instead of inheritance. It uses two independent class hierarchies, joined by an interface, so each side can change without affecting the other.

Key Points: • The abstraction hierarchy defines the high-level operations a client cares about. • The implementor hierarchy defines the low-level operations that actually carry out the work. • The abstraction holds a reference to the implementor interface rather than extending a concrete implementation class. • New abstractions and new implementations can each be added independently, without a combinatorial explosion of subclasses. • This is different from plain inheritance, where combining variations in two dimensions usually forces you to create a subclass for every pairing.

Example: A Shape abstraction (Circle, Square) can be rendered by different Renderer implementors (VectorRenderer, RasterRenderer); with Bridge, any shape can use any renderer without needing a RasterCircle and VectorCircle subclass pair.

Interview Tip: A concise interview answer is:

"Bridge decouples abstraction from implementation by connecting them through composition instead of inheritance, using two separate class hierarchies joined by an interface. That means I can add a new abstraction or a new implementation independently, without the subclass explosion you'd get trying to represent every combination through inheritance alone."