Design Patterns Flashcards

1
Q

In what groups can we divide the design patterns?

A

Creational, Structural and Behavioral design patterns

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

Why should we use creational patterns?

A

Creational patterns provide more flexibility in how the objects are actually created

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

Why should we use structural patterns?

A

Structural patterns deal with how inheritance and composition can be used to provide extra cuntionality

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

Why should we use behavioral patterns?

A

Behavioral patterns are about communication and assignment of responsibilities between our objects

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

What is the proxy pattern?

A
  • Structural design pattern
  • Provides a substitute for another object and controls access to that object, allowing you to perform something before or after the request reaches the original object
  • Can be used to e.g. cache the info of downloaded videos
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the decorator pattern?

A
  • Structural design pattern
  • The decorator pattern lets you attach new behaviors to an object by placing this object inside a special wrapper that contains these behaviors
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the adapter pattern?

A
  • Structural design pattern
  • It allows objects with incompatible interfaces to collaborate with one another
  • Idea: This pattern takes all of our XML data and transforms it to JSON making it compatible with the third party library we are making use of
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the bridge pattern?

A
  • Structural design pattern
  • The bridge pattern lets you split a large class into two separate hierarchies which can be developed independently -> divide and organize a single class that has multiple variants of some functionality into two hierarchies: abstractions and implementations
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the singleton pattern?

A
  • Creational design pattern
  • This pattern ensures that only one instance of its kind exists and provides a single point of access to it within our whole application
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the factory pattern?

A
  • Creational design pattern
  • This pattern makes it easy to extend the product construction code independently from the rest of the application -> Allows introducing new products without breaking existing code
  • Use this pattern if you have no idea of the exact types of the objects your code will work with
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the abstract factory pattern?

A
  • Creational design pattern
  • The abstract factory pattern allows you to produce families of related objects without specifying their concrete classes
  • Many designs start by using the factory method pattern and later evolve toward an abstract factory pattern
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the builder pattern?

A
  • Creational design pattern
  • The builder pattern produces different types and representations of an object using the same construction process
  • The builder pattern suggests that we extract the object construction or creation code out of its own class and move it to separate objects called builders
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the prototype pattern?

A
  • Creational design pattern
  • The prototype pattern delegates the object duplication or cloning process to the actual objects that are being cloned
  • Use the prototype pattern when your code should not depend on the concrete classes of the objects that you need to copy or duplicate
How well did you know this?
1
Not at all
2
3
4
5
Perfectly