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?

24
Q

What classification is the Chain of Responsibility pattern?

A

Object Behavioural

25
What is the intent of Chain of Responsibility?
Decouple the sender of a request from the receiver by giving more than one object a chance to handle request
26
What is it called when the object that makes a request has no explicit knowledge of who will handle it? (Chain of Responsibility)
Implicit Receiver
27
What are the 3 participants of the Chain of Responsibility pattern?
1. Handler 2. ConcreteHandler 3. Client
28
What 2 things are required in Chain of Responsibility handlers?
1. Interface to handle request 2. Accessor to Successor
29
What classification is the Visitor pattern?
Object Behavioural
30
What is the intent of the Visitor pattern?
To represent an operation to be performed on an existing class without changing that class
31
Visitor should be used when an object structure contains many differing _______ and you want to perform operations that depend on their _______ _______.
Interfaces Concrete Classes
32
Visitor should be used when classes defining object structure _______ _______ but you often _________ ________ __________.
Rarely Change Define New Operations
33
Visitor should be used when many ___________ operations need to be performed on objects and you want to avoid making interfaces _________.
Unrelated Bulky
34
What are the 5 participants of the Visitor pattern?
1. Visitor 2. ConcreteVisitor 3. Element 4. ConcreteElement 5. ObjectStructure
35
Which participant in Visitor defines an Accept operation?
Element
36
In the Visitor pattern, what does the Accept operation take as an argument?
Visitor
37
Which Visitor participant can enumerate its elements?
ObjectStructure
38
The Visitor pattern makes it difficult to add which participant?
ConcreteElement
39
What OOP principle can be broken because of Visitor?
Encapsulation
40
What is the intent of the MVC pattern?
Decouple visual and state classes
41
What does MVC stand for?
Model View Controller
42
What is the UI in MVC?
View
43
What is the internal state in the MVC?
Model
44
What is responsible for interaction in MVC?
Controller
45
What is considered the source of truth in the MVC?
Model
46
What has the responsibility of validating data in the MVC?
Controller
47
What is the classification of the Interpreter pattern?
Class Behavioural
48
What is the intent of the Interpreter pattern?
Describes how to define a grammar for simple languages, represent sentences in the language, and interpret these sentences
49
What is a grammar in the Interpreter pattern?
Set of rules that construct a string
50
What do you get when you combine all the expressions in a grammar?
Syntax Tree
51
What 2 things make the Interpreter pattern work best?
1. Simple Grammar 2. Efficiency not critical
52
What are the 5 participants of the Interpreter pattern?
1. AbstractExpression 2. TerminalExpression 3. NonterminalExpression 4. Context 5. Client
53
In the Interpreter pattern, the client has a sentence built as an abstract syntax tree of what 2 types of expressions?
Terminal and Nonterminal
54
Which type of expression defines the base case for the interpret recursion?
TerminalExpression
55
The Interpret() function uses what to store and access the interpreter's state?
Context
56
How does the NonterminalExpression define Interpret?
By the subexpression
57
What pattern is a syntax tree?
Composite