Bridge Pattern Flashcards

1
Q

What is the Bridge Pattern?

A

A structural design pattern that decouples an abstraction from its implementation, allowing both to vary independently.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When would you use the Bridge Pattern?

A

When you want to avoid a permanent binding between an abstraction and its implementation and both can change independently.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the components of the Bridge Pattern?

A
  • Abstraction
  • RefinedAbstraction
  • Implementation
  • ConcreteImplementation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the Abstraction component do in the Bridge Pattern?

A

Defines the high-level interface that the client uses.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the purpose of the RefinedAbstraction in the Bridge Pattern?

A

Extends the abstraction to add more specific behavior.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the role of the Implementation in the Bridge Pattern?

A

Defines the interface for implementation classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does ConcreteImplementation do?

A

Implements the implementation interface for specific platforms or variants.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a key advantage of the Bridge Pattern?

A

Separation of Concerns: Abstraction and implementation can evolve independently.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How does the Bridge Pattern promote extensibility?

A

New abstractions and implementations can be added without modifying existing code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a disadvantage of the Bridge Pattern?

A

Increased Complexity: Introduces additional classes and interfaces, which can make the code harder to understand.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How does the Bridge Pattern relate to the Adapter Pattern?

A

The Bridge Pattern decouples abstraction from implementation, while the Adapter Pattern makes incompatible interfaces work together.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the focus of the Strategy Pattern compared to the Bridge Pattern?

A

Strategy Pattern focuses on changing behavior dynamically, while Bridge Pattern focuses on separating abstraction and implementation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the purpose of creating concrete implementations in the Bridge Pattern?

A

To implement the implementation interface for each platform or variant.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Fill in the blank: The Bridge Pattern helps avoid _______.

A

class explosion.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

True or False: The Bridge Pattern is used to adapt existing classes to work together.

A

False.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a real-world analogy for the Bridge Pattern?

A

A remote control (abstraction) and a TV (implementation) that can work together without needing to change the remote when the TV changes.

17
Q

What happens without the Bridge Pattern when you have multiple dimensions?

A

You would need a separate subclass for every combination, leading to class explosion.

18
Q

What does the client code do in the Bridge Pattern?

A

Associates the abstraction with a concrete implementation and uses the abstraction.

19
Q

What is the UML diagram structure for the Bridge Pattern?