Question
Which of the following design patterns violates the
Open/Closed Principle of SOLID principles in object-oriented design?ÂSolution
The Singleton pattern violates the Open/Closed Principle of SOLID, which states that software entities (classes, modules, functions) should be open for extension but closed for modification. The Singleton pattern is designed to restrict the instantiation of a class to a single object. To achieve this, the class is tightly coupled to its own instance management logic, which means modifying or extending this behavior requires changes to the original class. As a result, Singleton classes are not easily extensible without modification, making them contrary to the Open/Closed Principle. Why Other Options are Incorrect: A) Strategy Pattern: The Strategy Pattern adheres to the Open/Closed Principle by allowing algorithms to be selected and applied at runtime without modifying existing code. C) Factory Method Pattern: This pattern promotes extensibility by allowing subclasses to alter the type of objects that will be created, without modifying the client code. D) Decorator Pattern: The Decorator Pattern is designed to extend functionality dynamically by wrapping objects, adhering to the Open/Closed Principle. E) Adapter Pattern: The Adapter Pattern allows for existing classes to be used without modification by adapting their interfaces to a new target interface, following the Open/Closed Principle.
Which of the following Key Employment Indicators is/are incorrectly matched?
Which of the following is/are the determinants of MSP?
(i) Cost of Production
(ii) demand and supply
(iii) price trend
...How much amount has been invested by World Bank since the implementation of Pradhan Mantri Gram Sadak Yojna (PMGSY)?
What is the name of the NRLM Mobile App to give facilities of e-Commerce?
Ministry of Agriculture and Farmers’ Welfare has approved the continuation of the Integrated Scheme for Agricultural Marketing (ISAM) scheme up to ___...
Which of the following is NOT a feature of the Targeted Public Distribution System (TPDS) under the NFSA?
Which of the following is the objectives of PM PRANAM scheme?
When was the AMRUT Scheme launched?
How many additional rural and urban households will be provided assistance for house construction under the Pradhan Mantri Awas Yojana (PMAY)?
Which of the following is the theme for recently conducted Economic Times Global Business Summit 2023?