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.
__________is the process that connects to a network without the use of cables.
If × stands for addition, ÷ stands for subtraction. + stands for multiplication and ̶ stands for division, then what is the value of 20 &t...
A sum of Rs. 663 is divided among X, Y and Z such that X gets Rs. 156 more than Y. Y gets Rs. 78 more than Z. Find the share of Z?
In a mixture 'P', 5 liters of water are replaced with honey, resulting in the mixture containing 55% honey. If the original mixtu...
A ________________ typically connects personal computers within a very limited geographical area, usually within a single building.
Formatting a disk means?
A sum of Rs.8200 is to be divided among 6 brothers, 5 sisters and 2 aunts. If each sister receives thrice as much as each aunt and each brother receives...
Ehsaan is twice as good a worker as Kamal and together they finish a piece of work in 29 days. In how many days will Kamal, working alone, finish the wo...
₹ 1,800 is divided among Nitin, Tushar and Gitanjali. The share of Gitanjali is 5/4 of the sum of the shares of Nitin and Tushar. What is the share of...
The number of five–digit telephone numbers having at least one of their digits repeated is