kec 31: behavioural design patterns, part 1

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/14

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 9:41 PM on 4/13/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

15 Terms

1
New cards

What are behavioural design patterns concerned with?

Algorithms and the assignment of responsibilities between objects.

2
New cards

What are the two types of behavioural patterns listed in the slides?

Class behavioural and object behavioural.

3
New cards

What pattern is the main focus of this deck?

State.

4
New cards

What is the definition of the State pattern?

Allow an object to alter its behaviour when its internal state changes; the object will appear to change its class.

5
New cards

What is the main problem in the naive LineOfCredit design?

Big if/switch statements based on the current state.

6
New cards

What states does the LineOfCredit example use?

New, Applied, Open, Cancelled.

7
New cards

What operations does the LineOfCredit example include?

apply, approve, withdraw, makePayment, cancel.

8
New cards

What replaces the enum in the State pattern version?

A pointer/reference to a state object.

9
New cards

What does the context object do in the State pattern?

It delegates requests to the current state object.

10
New cards

What does the base LineOfCreditState class provide?

Virtual operations for all possible actions, often with default invalid-state behavior.

11
New cards

What happens in AppliedState::approve()?

The state changes to OpenState.

12
New cards

What happens in AppliedState::cancel()?

The state changes to CancelledState.

13
New cards

What does OpenState::withdraw() do?

It checks available credit and increases balance owing if allowed.

14
New cards

What is one consequence of the State pattern?

It localizes state-specific behavior.

15
New cards

What is another consequence of the State pattern?

It makes state transitions explicit.