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.
Amount of water in 5 ha cm will be
What is the main aim of an integrated farming system?
Which among the following is Erosion ‐ resistance crop?
What is the primary source of energy used for solar lighting, solar refrigeration, and solar dryers?
Application of super digested compost to acidic calcareous and heavy soils increases the availability of
When One Seller sells a Product, but the product has no close substitute, it is called:
An anticodon is a sequence of three nitrogenous bases found on:
The ratio of actual vapour pressure to the saturated pressure is known as:
Why are forests important for mitigating climate change?
Which of the following Traceability system is offered by APEDA for Organic Products?