What is SRP?

 Posted by SheoNarayan on 11/11/2008 | Category: Design Pattern & Practices Interview questions | Views: 12250

SRP stands for Single Responsibility Principle. This states that a class should have only one reason to change. If a class is doing too much (i.e. hitting the DB, writing files, doing business logic, calling a web service, etc, it’s violating SRP. It will be very difficult to change later should we need to change it, and it will likely be prone to have more defects.

SRP applies to the methods or in a class also. The two are inseparable. A class, or object, is the combination of its data and its behavior.

For more details read this document: Single Responsibility Principle

Source: With input from Chad Myers

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response