Design Patterns Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is the basis of almost all design patterns?

A

All patterns find some way to let some part of the system vary without affecting other parts.

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

What is the intent of the Strategy Pattern?

A

The intent of the Strategy Pattern is to define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithms vary independently from the clients that use it.

Strategy also captures the abstraction in an interface, and buries the implementation details in the derived class.

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

What is the intent of the Observer Pattern?

A

The intent of the Observer Pattern is to define a one-to-many dependency between objects so when one objects changes states, all of its dependents are notified and updated automatically.

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

What is the concept of loose coupling and what design pattern makes use of it?

A

Objects are loosely coupled when they can interact with each other but they have very little knowledge of each other.

The Observer Pattern makes use of this concept.

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

What are the classes involved in Java’s built-in Observer Pattern and what do they allow you to do?

A

The Observable class (which is the Subject) and the Observer class. They allow for a push or pull style of information from the subject.

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

What is the intent of the Decorator Pattern?

A

The intent of the Decorator Pattern is to attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.

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

Which Java package is largely based on the Decorator Pattern?

A

The java.io package is mostly based on the Decorator Pattern.

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

What is the intent of the Factory Pattern?

A

The intent of the Factory Pattern is to define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.

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

What is the intent of the Singleton Pattern?

A

The intent of the Singleton Pattern is to ensure that a class has only instance and provides a global point of access to it.

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

What is the intent of the Command Pattern?

A

The intent of the Command Pattern is to encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.

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

What is the intent of the Adapter Pattern?

A

The intent of the Adapter Pattern is convert the interface of a class into another interface the clients expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces.

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

What is the intent of the Facade Pattern?

A

The intent of the Facade Pattern is to provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.

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

What is the intent of the Template Method Pattern?

A

The intent of the Template Method Pattern is to define the skeleton of an algorithm in a method, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm’s structure.

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