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.
In which sport is the term 'Dolphin Kick' commonly used?
Which of the following river is not started from western India?
What is the minimum net-owned fund requirement for an NBFC?
Recently Parliament passes bill to raise Nabard’s capital to Rs _____.
As of 2020, which country has the largest proven coal reserves in the world?
In the light of the revealed preference theory, consider the following options and select the right answer from the codes given below.
a. Rationa...
A train crosses two platforms of length 1000 m and 600 m in 80 seconds and 60 seconds, respectively. What is the length of the train?
Each of the following questions consists of a word printed in capital letters, followed by four words or phrases. Choose the word or phrase that is most...
The festival 'Jude Sheetal' is celebrated in which Indian state?
India is investing $82 billion in foreign ports by 2035. Which of these is NOT included?