Question
Which SOLID principle emphasizes that software entities
should be open for extension but closed for modification?Solution
The Open/Closed Principle (OCP) is one of the SOLID principles for object-oriented design. 1. Key Idea: Software entities like classes, modules, and functions should be extendable without altering existing code. 2. Implementation: Achieved through techniques like inheritance, polymorphism, or interfaces that allow new functionality to be added without modifying the original codebase. 3. Benefits: Promotes code reusability, reduces the risk of introducing bugs into stable code, and facilitates easier maintenance and scaling. 4. Example: A class for processing payments could use an interface for payment methods. Adding a new payment type would require extending the interface, not modifying the class. This principle ensures that software systems are adaptable to new requirements without jeopardizing existing functionality. Why Other Options Are Incorrect: • A) SRP: Focuses on assigning one responsibility to each class/module but does not address extensibility. • C) LSP: Ensures derived classes can replace base classes without altering behavior, unrelated to modification. • D) ISP: Advocates for creating specific interfaces for clients, reducing unnecessary dependencies. • E) DIP: Encourages high-level modules to depend on abstractions rather than concrete implementations.
Which of the following is Principals duty towards an Agent?
Which section of the Companies Act, 2013 deals with the penalty for violation of any section or rules for which no specific penalty is defined?
Which of the following can be included as a property of the partnership firm?
Surrender of certificate of security is made to the …
Professional communications made under S. 126 of the Indian Evidence Act, 1872 are applicable to:
Under Section 320(1) of Cr.PC for fraudulent removal or concealment of property etc. to prevent distribution among creditors, which section of IPC is ap...
As per s. 31 of CPC summons can be issued to a __________?
What is the condition for an action or belief to be considered in "good faith" as per IPC?
Which of the following is a ground for divorce under the Hindu Marriage Act?
Under Food Safety and Standards Act, who shall establish Special Courts for trial of offences relating to grievous injury or death?