Behavioural Patterns Flashcards

1
Q

What is the purpose of the ‘Chain of Responsibility’ pattern?

A

To avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.

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

What is the purpose of the ‘Command’ pattern?

A

To encapsulate a request as an object, thereby letting you parameterise clients with different requests, queue or log requests, and support undoable operations.

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

What is the purpose of the ‘Iterator’ pattern?

A

To provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

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

What is the purpose of the ‘Memento’ pattern?

A

To capture and externalise an object’s internal state, without violating encapsulation, so that it can be restored to this state later.

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

What is the purpose of the ‘Observer’ pattern?

A

To define a one-to-many dependency between objects so that when one object changes its state, all its dependants are notified and updated automatically.

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

What is the purpose of the ‘Strategy’ pattern?

A

To define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.

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

What is the purpose of the ‘Template Method’ pattern?

A

To define the skeleton of an algorithm in a method, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm’s structure.

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