Lecture 8-State pattern Flashcards

1
Q

What is the intent of the state pattern?

A

To allow an object to alter its behaviour when its internal state changed.

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

What are the pros of the state pattern?(3)

A

-SRP: organize the code related to particular states into separate classes.
-Open/Closed principle: introduce new states without changing existing state classes of the context.
-Eliminate bully state machine conditionals.

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

What are the cons of the state pattern?

A

-If state machine has only a few state or rarely changes–> might be overkill

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