Question
Which design pattern is best suited for managing the
creation of objects without specifying their concrete classes?Solution
The Factory Pattern is a creational design pattern that provides an interface for creating objects in a superclass but allows subclasses to alter the type of objects that will be created. It abstracts the instantiation process, enabling flexibility and scalability in object creation. For instance, in a GUI framework, the factory method might create different types of buttons (WindowsButton, MacButton) depending on the operating system. By decoupling the client code from concrete classes, this pattern promotes adherence to the Open/Closed Principle of SOLID. Why Other Options Are Incorrect :
- Singleton Pattern : This ensures a class has only one instance and provides global access to it, unrelated to flexible object creation.
- Observer Pattern : This defines a one-to-many dependency, where changes in one object are notified to multiple observers.
- Adapter Pattern : This works as a bridge between incompatible interfaces, not for object creation.
- Decorator Pattern : This adds functionality dynamically to objects, without modifying their structure.
What is the estimated combined GDP of the Eurasian Economic Union (EAEU) as per the latest trade discussions with India?
The 11th Session of the India-Russia Working Group on Modernization & Industrial Cooperation was co-chaired by Amardeep Singh Bhatia and:
As per CCPI, 2023; India is the only G-20 country in the top 10 ranks. The first three ranks in the overall ranking were grabbed by
Milk Price Incentive Scheme is launched by ____________.
Which of the state movies has been nominated for the International Short film festival?
Union Agriculture Minister Tomar inaugurates the Multipurpose Mega Farmers Fair in which of the following state?
Who has launched the mobile application 'Rajmargyatra'?
Jammu and Kashmir Bank (J&K Bank) has signed a corporate agency agreement with______ to put forward LIC’s life insurance products through its branch n...
What does the newly launched RailOne app by Indian Railways offer a 3% discount on?Â
To whom is UNESCO dedicating International Day of Education 2024, emphasizing the urgent need to lift restrictions on their access to education?