Seminar 2 Flashcards

1
Q

What is the Mediator pattern?

A

Defines an object that encapsulates how a set of objects interact/communicate. Instead of having each component refer to and communicate directly with the others (which creates tight coupling), the components communicate through a Mediator object.

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

Is the Mediator pattern behavioral, structural, or creational?

A

Behavioral.

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

When should you use the Mediator pattern?

A

When a system has complex interactions between multiple components.

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

What are the benefits of the Mediator pattern?

A

Reduces coupling, improves readability, centralizes communication.

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

What are the drawbacks of the Mediator pattern?

A

Can become a ‘god object’ and introduce performance overhead.

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

What is the Composite pattern?

A

A structural pattern that allows composing objects into tree structures.
* You define a common interface (e.g., Component) for both simple and complex elements.

  • Leaf: A basic element (e.g., a file).
  • Composite: A container that holds leaf or other composite elements (e.g., a folder).
  • Each composite can contain children and delegates operations to them.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the benefits of the Composite pattern?

A

Simplifies client code, encourages polymorphism, improves scalability.

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

What are the drawbacks of the Composite pattern?

A

Can overly generalize the system and complicate debugging.

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

When should you use the Composite pattern?

A

When you want to treat individual objects and compositions the same way.

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

What are the key roles in the Composite pattern?

A

Component, Leaf, Composite.

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

What is the Iterator pattern?

A

A behavioral pattern for traversing elements without exposing their representation.

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

What are the benefits of the Iterator pattern?

A

Decouples traversal logic, supports multiple iteration styles.

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

What are the drawbacks of the Iterator pattern?

A

Adds extra classes and can be inefficient for simple collections.

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

When should you use the Iterator pattern?

A

When direct access is inefficient or multiple iteration styles are needed.

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

What are the key roles in the Iterator pattern?

A

Iterator, ConcreteIterator, Aggregate, ConcreteAggregate.

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

What is the Object Pool pattern?

A

Reuses expensive-to-create objects by managing them in a pool.

17
Q

What are the benefits of the Object Pool pattern?

A

Improves performance, reduces memory use, manages heavy resources.

18
Q

What are the drawbacks of the Object Pool pattern?

A

Requires object reset, is hard to manage with threads, unsuitable for light objects.

19
Q

When should you use the Object Pool pattern?

A

When object creation is expensive or many similar objects are needed.

20
Q

What are the key roles in the Object Pool pattern?

A

ObjectPool, Reusable, Client.