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.
Recently, which state has launched its first major education project – ‘Schools of Eminence’?
Which award did Nobel Peace Prize laureate Rigoberta Menchú Tum receive recently?
Who has been appointed as the new chief of Research and Analysis Wing (RAW)?
The Council of Scientific and Industrial Research (CSIR) and_______ has inked an umbrella Memorandum of Understanding (MoU) to pursue technological part...
Recently West Bengal Government hand over its Tajpur Port to which of the following company?
How has India’s fossil fuel subsidy in the oil and gas sector changed from 2013 to 2023, according to the Asian Development Bank (ADB)?
The Pradhan Mantri Jan Dhan Yojana (PMJDY), launched in 2014, reached the significant milestone of 500 million accounts. Among these, ______ percent of ...
What is the primary goal of Uttar Pradesh’s planned private textile parks?
Which of the following statements regarding the RBI Governor Shaktikanta Das and his ranking as a central banker is correct?
1. RBI Governor Shak...
Which technology did Tesla integrate into their Model S vehicles in 2024 to improve autonomous driving?