Flashcards in Design Patterns Deck (6)
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?
1. 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.