SOFTWARE ENGINEERING

SOFTWARE DESIGN

DESIGN PATTERNS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Where is the use of Singleton recommended?
A
When a class in your program must have only one instance available to all of its clients
B
When you are in a hurry and want to create a class with a single click
C
When a class is used frequently at various points in the system
D
When you don’t know the types and dependencies of objects
Explanation: 

Detailed explanation-1: -The singleton class must provide a global access point to get the instance of the class. Singleton pattern is used for logging, drivers objects, caching, and thread pool. Singleton design pattern is also used in other design patterns like Abstract Factory, Builder, Prototype, Facade, etc.

Detailed explanation-2: -Singleton Design Pattern is one of the easiest and straightforward patterns to be implemented in an automation framework. This design is used when we need to use the same object of a class across the automation framework. It restricts the instantiation of a class to a single instance.

Detailed explanation-3: -Global Access Point. A Singleton is a global object in disguise, but it provides a global access point. Unique Entity Model. It makes it easier to reason about your program when you model entities of reality. Static Initialization Order Fiasco. Concurrency. Too often used. Hidden Dependency. 25-Sept-2022

There is 1 question to complete.