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.
√323.89 × (3.20) ÷ 9.02 = ?
In 2017, Sunny invested Rs 3500 at S.I and rest at C.I. If the total amount received after respective time is Rs 8960, then find the time for which the ...
In 2015, the difference between compound interest and simple interest for the given time is Rs 20. If the sum is invested for 3 years, what will be the ...
What is the percentage profit (approximate) on selling dates if its selling price is 120% of the selling price of Raisins?
If number of staff members in Patna is 10% less than number of staff members in Chandigarh,in which city the total staff members who work in Credit depa...
If the percentage of profit on selling Almonds is 25%, then what is its cost of packaging?
In 2014, if rate of interest is increased by 3%, what will be the amount received after given time?
If the total number of persons who attended the workshop in 2016 is 324, then what is the total number of Professors who attended the workshop in all t...
In 2016, the interest was semi-annually, the interest would have been Rs 1030.402 for given time. Find the interest when compounded annually.
In 2013, the amount becomes Rs 28,700 after 8 years, find the rate of interest.