Exam(2024) Flashcards

1
Q

What classification is the Proxy pattern?

A

Object Structural

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

What else is the Proxy pattern known as?

A

Surrogate

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

What is the intent of the Proxy pattern?

A

Provide a placeholder for another object to control access to it

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

What is the motivation for using the Proxy pattern?

A

Defer full cost of its creation until we actually need to use it

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

What are the 4 types of proxies? (Retarded Village People Smell)

A
  1. Remote Proxy
  2. Virtual Proxy
  3. Protection Proxy
  4. Smart Reference
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

A smart pointer is an example of what kind of proxy?

A

Smart Reference

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

What kind of proxy creates an expensive object on demand?

A

Virtual Proxy

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

What are the 3 participants of the Proxy pattern?

A
  1. Proxy
  2. Subject
  3. RealSubject
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do the Proxy and the RealSubject interact?

A

Proxy forwards requests to RealSubject when appropriate

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

What is it called when the Proxy pattern defers copying a large and complicated object until ensuring there has been a change to the object?

A

copy-on-write

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

What classification is the Command pattern?

A

Object Behavioural

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

What is the intent of the Command pattern?

A

Encapsulate a request as an object

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

What else is the Command pattern known as?

A

Action, Transaction

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

What is the motivation for the Command pattern?

A

Allow an object to make requests to unknown or variable receivers by making the request an object

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

What are the 5 participants of the Commander pattern?

A
  1. Command
  2. ConcreteCommand
  3. Client
  4. Invoker
  5. Receiver
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which participant of the Commander pattern defines a binding between a Receiver object and an action?

A

ConcreteCommand

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

ConcreteCommand implements which function that invokes corresponding operations on Receiver?

A

Execute

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

What creates the ConcreteCommand and specifies its Receiver?

A

Client

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

What stores the ConcreteCommand object?

A

Invoker

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

What stores state for undoing a command when applicable?

A

ConcreteCommand

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

Command decouples the object that invokes the operation from what?

A

The object that knows how to perform it

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

What pattern can be used to combine many commands to create a MacroCommand class?

A

Composite

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

What pattern can be used to implement Undos in the Command pattern?

A

Mementos

24
Q

What classification is the Chain of Responsibility pattern?

A

Object Behavioural

25
Q

What is the intent of Chain of Responsibility?

A

Decouple the sender of a request from the receiver by giving more than one object a chance to handle request

26
Q

What is it called when the object that makes a request has no explicit knowledge of who will handle it? (Chain of Responsibility)

A

Implicit Receiver

27
Q

What are the 3 participants of the Chain of Responsibility pattern?

A
  1. Handler
  2. ConcreteHandler
  3. Client
28
Q

What 2 things are required in Chain of Responsibility handlers?

A
  1. Interface to handle request
  2. Accessor to Successor
29
Q

What classification is the Visitor pattern?

A

Object Behavioural

30
Q

What is the intent of the Visitor pattern?

A

To represent an operation to be performed on an existing class without changing that class

31
Q

Visitor should be used when an object structure contains many differing _______ and you want to perform operations that depend on their _______ _______.

A

Interfaces
Concrete Classes

32
Q

Visitor should be used when classes defining object structure _______ _______ but you often _________ ________ __________.

A

Rarely Change
Define New Operations

33
Q

Visitor should be used when many ___________ operations need to be performed on objects and you want to avoid making interfaces _________.

A

Unrelated
Bulky

34
Q

What are the 5 participants of the Visitor pattern?

A
  1. Visitor
  2. ConcreteVisitor
  3. Element
  4. ConcreteElement
  5. ObjectStructure
35
Q

Which participant in Visitor defines an Accept operation?

A

Element

36
Q

In the Visitor pattern, what does the Accept operation take as an argument?

A

Visitor

37
Q

Which Visitor participant can enumerate its elements?

A

ObjectStructure

38
Q

The Visitor pattern makes it difficult to add which participant?

A

ConcreteElement

39
Q

What OOP principle can be broken because of Visitor?

A

Encapsulation

40
Q

What is the intent of the MVC pattern?

A

Decouple visual and state classes

41
Q

What does MVC stand for?

A

Model View Controller

42
Q

What is the UI in MVC?

A

View

43
Q

What is the internal state in the MVC?

A

Model

44
Q

What is responsible for interaction in MVC?

A

Controller

45
Q

What is considered the source of truth in the MVC?

A

Model

46
Q

What has the responsibility of validating data in the MVC?

A

Controller

47
Q

What is the classification of the Interpreter pattern?

A

Class Behavioural

48
Q

What is the intent of the Interpreter pattern?

A

Describes how to define a grammar for simple languages,
represent sentences in the language, and interpret these sentences

49
Q

What is a grammar in the Interpreter pattern?

A

Set of rules that construct a string

50
Q

What do you get when you combine all the expressions in a grammar?

A

Syntax Tree

51
Q

What 2 things make the Interpreter pattern work best?

A
  1. Simple Grammar
  2. Efficiency not critical
52
Q

What are the 5 participants of the Interpreter pattern?

A
  1. AbstractExpression
  2. TerminalExpression
  3. NonterminalExpression
  4. Context
  5. Client
53
Q

In the Interpreter pattern, the client has a sentence built as an abstract syntax tree of what 2 types of expressions?

A

Terminal and Nonterminal

54
Q

Which type of expression defines the base case for the interpret recursion?

A

TerminalExpression

55
Q

The Interpret() function uses what to store and access the interpreter’s state?

A

Context

56
Q

How does the NonterminalExpression define Interpret?

A

By the subexpression

57
Q

What pattern is a syntax tree?

A

Composite