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 indicates the system introduced by Lord Cornwallis granting legal ownership of land to the zamindars in Bengal in order to get a ...
Which Article of the Constitution of India provides for universal adult suffrage?
From which country are the 'Fundamental Duties of the Indian Constitution borrowed?
Chitrakoot district is situated in which of the following state ?
Consider the following reaction:
2H₂ (g) + O₂ (g) → 2H₂ O(l)
Which one of the following statements about the reaction given above is correct?
What is the process of a substance changing directly from a solid to a gas without passing through the liquid state called?
India’s proposed manned mission to space by ISRO is named as
If a side of a cube is 6 cm, then find its volume.
Where was the first 'Open Rock Museum' inaugurated by the Union Minister of State for Science & Technology and Earth Sciences, on January 6, 2021?
Gunmetal is an alloy of: