Question
Which SOLID principle emphasizes that a class should
have only one reason to change?Solution
The Single Responsibility Principle (SRP) in SOLID design principles states that a class should have only one reason to change, meaning it should encapsulate only one responsibility. This principle promotes cohesion and ensures that each class handles a single task or functionality. For instance, in an inventory management system, a Product class should handle product-related data only, while a separate Inventory class manages stock levels. Adhering to SRP reduces complexity, makes code easier to understand, and simplifies debugging and testing. By isolating responsibilities, developers can introduce changes without affecting unrelated parts of the system. Why Other Options Are Incorrect :
- Open/Closed Principle : Focuses on extending classes without modifying existing code, not on single responsibility.
- Liskov Substitution Principle : Ensures that derived classes can be substituted for their base classes without breaking functionality.
- Dependency Inversion Principle : Encourages dependency on abstractions rather than concrete implementations, unrelated to single responsibilities.
- Interface Segregation Principle : Suggests splitting large interfaces into smaller, specific ones, focusing on interface design, not class responsibilities.
What is the purpose of setting up of Small Finance Banks (SFBs) in India?
1. To supply credit to small business units
2. To supply credit ...
What is the World Bank's stated official goal?
All revenues received by the Union Government by way of taxes and other receipts for the conduct of Government business are credited to the?
Consider the following statements with respect to the International Labour Organisation-
I.It is the only tripartite United Nation (UN) agency. I...
Which of the following components of the Forex Reserves of India forms the smallest part in terms of value ?
Which of the following Organisation collaborated with the Ministry of MSME and Energy Efficiency Services Ltd to Implement Energy efficiency Project in ...
As per the Centre for Economics and Business Research, India will become the third largest economy by ____________.
Given CRR = 4 % and SLR = 16 % , the value of the money multiplier is:
The 'Ration Aapke Gram' scheme was recently launched in _____________.
‘SWAYAM’, an initiative of the Government of India, aims at