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 I/O scheduling, which of the following algorithms minimizes seek time but may lead to starvation of requests at the ends of the disk?ย
- In a CI/CD pipeline, which of the following represents the most critical failure point that could delay the entire software release cycle?ย
- In the context of virtualization, paravirtualization differs from full virtualization in which of the following ways?ย
- Data mart types
- Which of the following best describes the concept of abstraction in object-oriented programming (OOP)?ย
- What will be the output of the following code snippet implementing the Least Recently Used (LRU) page replacement algorithm? def lru(pages, capacity): ย ย ...
- In the context of web development, which of the following best describes the primary difference between HTTP and HTTPS?
- The time horizon of data warehouse is
- Java. Lang package
- What is a common security control used to protect sensitive data during transmission over the internet?