Design Patterns Flashcards

1
Q

Which pattern is used for 1 to many relationships between objects?

A

Observer Pattern

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

What are the actors used in observer patterns?

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

What is a subject(Observable) actor in the Observer pattern?

A

It holds methods to attach and detach the observers to the client. it is a concrete class that extends the observer class

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

What is an Observer?

A

The observer is an abstract class with all the methods

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

What are design patterns?

A

Capture the best practice of experienced object-oriented s/w developers

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

What are the essential elements of patterns?

A
  1. Name
  2. Problem and its context
  3. Solution with an abstract description
  4. Consequences
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Types of design patterns?

A

Creational Patterns
Structural Patterns
State Patterns
Command patterns

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

What are creational Patterns?

A

Create an object for you rather than having you to instantiate an object

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

What are Structural Patterns?

A

how to group. and organize classes

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

What are state patterns?

A

Class behavior changes on the basis of State

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

What are the elements of the state pattern?

A
  1. Context
  2. State
  3. ConcreteState
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Context in state pattern?

A

The object whose behavior needs to be state-specific
It will have reference to a concrete state, which defines the current state of the context object. The state is proportional to Context.

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

What is State class in State Pattern?

A

It is implemented as an abstract class/Interface

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

What is a Concrete State in State Pattern?

A

The class that implements state-specific behavior, have the implementation of setState()

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

What is a Command Pattern?

A

It is a data-driven design pattern and falls under the behavior pattern category

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

What are the elements of Command Pattern?

A
  1. Interface acts as a command
  2. Class that acts as a request.
  3. Concrete command classes implementing the interface
  4. Class which act as an invoker object.
17
Q

What are Strategy Patterns?

A

They are used when behavior changes are needed dynamically during runtime

18
Q

What is the intent of Strategy Patterns?

A
  1. Define a group of algorithms that applies to a family of classes
  2. Encapsulate each algorithm separately
  3. Make the algorithms interchangeable within that family
19
Q

What is the consequence of Strategy Patterns?

A

The Strategy Pattern lets the specific algorithm implemented by a method vary without affecting the clients that use it.

20
Q

What are the elements of Strategy Patterns?

A
  1. Context
  2. Strategy Interface
  3. Concrete Strategy classes that implement Strategy Interface
21
Q

What are Adapter Patterns?

A

It allows the classes to work together with incompatible types

22
Q

What is the intent of Adapter Patterns?

A
  1. Convert the interface of a class into another interface that clients expect.
  2. The adapter lets classes work together, which could not otherwise because of incompatible interfaces.
23
Q

What are the elements of the Adapter Pattern?

A

Target - defines the domain-specific interface that the Client uses.
Adapter - adapts the interface Adaptee to the Target interface.
Adaptee - defines an existing interface that needs adapting.
Client - collaborates with objects conforming to the Target interface.