Design Patterns Flashcards
What is Singleton Pattern?
Singleton pattern is when only one instance of a class is created which will be available to the whole application.
What are the advantages of the Singleton Pattern?
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.
What are the drawbacks of using the Singleton Pattern?
- Singleton causes code to be tightly coupled.
2. Singleton Pattern does not support inheritance.
What is the Factory Pattern?
The Factory Pattern uses an interface or abstract class for creating an object but lets the sub-classes decide which class to instantiate.
What are the advantages of the Factory Pattern?
The Factory Pattern hides creation logic from dependent code and allows for loosely coupled code.
What is Lazy Loading?
Lazy Loading refers to deferring object initialization until the first time the object is needed.