Design Patterns Flashcards

1
Q

What is a factory?

A

method that wraps a constructor/methods that create objects

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

what is an abstract factory?

A

method that creates objects and doesn’t specify class

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

what is a builder?

A

object that can create other objects, can store configurations

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

what is an injector?

A

creates/imports target objects and injects them into the target object during creation. Thus, the target object does not create its has-a fields

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

what is lazy initiation?

A

defer creating an object until absolutely necessary, commonly a pointer stores the reference to the object and it set to null in the beginning

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

what is singleton?

A

only one object for a class. shared across thread/tasks

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

what is multiton?

A

multiple but finite objects for a class, stored in a collection (e.g. map) controlled access/allocation

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

what is an adapter?

A

converts an interface to another and connects two systems, useful when not possible to change existing structures

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

what is a bridge?

A

allows implementations to vary, allows objects to vary

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

what is a composite?

A

enables treating members of trees (or graphs) in the same way regardless if there are terminal, middle roots, etc.

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

what is a twin?

A

work around for multiple inheritance, clients refer only to one of the two objects directly, depending on their design. Interfaces could be used for further abstraction. Multi-implementation of interfaces is normally allowed.

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

what is an iterator?

A

go through all elements of a collection and run a method on each

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

what is a thread pool?

A

creates N threads, add tasks in the pools queue and each thread taks the next task from the queue and runs it.

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

what is read/write lock

A

allows only one writer to lock and multiple readers can read

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