Exam 3 Flashcards

1
Q

GoF patterns are classified based on three purpose categories: creational, structural and behavioral patterns. Which one of the following is not what GoF (Gang of Four) behavioral patterns are concerned with?
algorithms
how objects are created
patterns of communications between objects
assignment of responsibilities between objects
patterns of objects and classes

A

how objects are created

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

Which of the following is true with GoF deisgn patterns?
Factory method is useful when the product consists of subparts and one wants to vary the the types of subparts used.
Command pattern separates (or decouples) the invoker from the receiver by creating an interface in-between them.
Abstract factory pattern is used when one wants to treat elements in a composite structure uniformly.
Abstract factory or broker is needed for structure for building recursive aggregations.

A

Command pattern separates (or decouples) the invoker from the receiver by creating an interface in-between them.

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

Which of the following is the one best answer to the question “why is the Facade pattern a useful wrapper for a subsystem”?
It prevents clients from directly using system objects.
It tightly couples a subsystem to its clients.
It provides a simple interface for clients to use a complex subsystem.
It prevents subsystem classes from directly referencing client objects.
All of the above.

A

It provides a simple interface for clients to use a complex subsystem.

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

Why is a Singleton pattern used?
To insure that an abstract class has only one concrete subclass.
To make sure that an object can have only one distinct value that persists.
To insure that there is only a single clone of a particular object.
To insure that there is only one instance of a particular class.
To limit constructors to operate only once during a thread’s execution.

A

To insure that there is only one instance of a particular class.

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

Which design pattern best matches with the following description?

It accesses elements of a container without exposing its representation. It is useful when multiple traversal algorithms are required over a container but a uniform traversal interface over different containers is desirable.
Observer Pattern
Composite Pattern
Abstract Factory
Adaptor Pattern
Strategy Pattern
Iterator
Command
Visitor
Decorator

A

Iterator

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

Which design pattern best matches with the following description?

It centralizes operations on an object structure so that they can vary independently but still behave polymorphically. It is useful when classes define many unrelated operations and class relationships of objects in the structure rarely change, but the operations on them change often.
Observer Pattern
Composite Pattern
Abstract Factory
Adaptor Pattern
Strategy Pattern
Iterator
Command
Visitor

A

Visitor

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

Which design pattern best matches with the following description?

It converts the interface of a class into an interface that a client expects and allows incompatible classes to work together. It is useful when one needs to adapt the interface of an existing class to satisfy client interface requirements (e.g., legacy software, 3rd party software).
Observer Pattern
Decorator Pattern
Abstract Factory
Adaptor Pattern
Strategy Pattern
Iterator
Command
Visitor

A

Adaptor Pattern

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

Which design pattern best matches with the following description?
It creates families of related objects without specifying class names and is used when clients cannot anticipate groups of classes to instantiate.
Observer Pattern
Composite Pattern
Abstract Factory
Adaptor Pattern
Strategy Pattern
Iterator
Command
Visitor

A

Abstract Factory

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

Which design pattern best matches with the following description?

It defines a one-to-many dependency between objects so that all dependents are notified & updated when one object changes its state.
Observer Pattern
Composite Pattern
Abstract Factory
Adaptor Pattern
Strategy Pattern
Decorator
Command
Visitor

A

Observer Pattern

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

Which design pattern best matches with the following description?

It is used when we want to augment objects with new responsibilities but extension by subclassing is impractical.
Observer Pattern
Composite Pattern
Abstract Factory
Adaptor Pattern
Decorator Pattern
Iterator
Command
Visitor

A

Decorator Pattern

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

Which design pattern best matches with the following description?

It defines a family of algorithms, and encapsulates each algorithm to make entire algorithms interchangeable. It is useful when an object should be configurable with one of many algorithms, and all algorithms can be encapsulated, and one interface covers all encapsulations. [Hint: encapsulating each collision detection algorithm]
Observer Pattern
Composite Pattern
Abstract Factory
Adaptor Pattern
Strategy Pattern
Iterator
Command
Visitor

A

Strategy Pattern

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

Which design pattern best matches with the following description?

It encapsulates the request for a service and is used to parameterize objects with an action to perform and to specify, queue, & execute requests at different times. It allows a multilevel undo/redo typically.
Observer Pattern
Composite Pattern
Abstract Factory
Adaptor Pattern
Strategy Pattern
Iterator
Command
Visitor

A

Command

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

Which design pattern best matches with the following description?

It is used when objects must be composed recursively, and no distinction between individual & composed elements, and objects in structure can be treated uniformly.
Observer Pattern
Composite Pattern
Abstract Factory
Adaptor Pattern
Strategy Pattern
Iterator
Command
Visitor

A

Composite Pattern

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

GoF patterns are classified based on three purpose categories: creational, structural, and behavioral patterns. Which one of the following is not what GoF (Gang of Four) behavioral patterns are concerned with?
patterns of communications between objects
assignment of responsibilities between objects
algorithms
patterns of objects and classes
how objects are created

A

how objects are created

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