Design Patterns Flashcards

1
Q

What is Singleton Pattern?

A

Singleton pattern is when only one instance of a class is created which will be available to the whole application.

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

What are the advantages of the Singleton Pattern?

A

The Singleton pattern saves memory because a single instance of a class is reused again and again without needing to create a new object for each request.

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

What are the drawbacks of using the Singleton Pattern?

A
  1. Singleton causes code to be tightly coupled.

2. Singleton Pattern does not support inheritance.

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

What is the Factory Pattern?

A

The Factory Pattern uses an interface or abstract class for creating an object but lets the sub-classes decide which class to instantiate.

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

What are the advantages of the Factory Pattern?

A

The Factory Pattern hides creation logic from dependent code and allows for loosely coupled code.

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

What is Lazy Loading?

A

Lazy Loading refers to deferring object initialization until the first time the object is needed.

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