views:

339

answers:

5

What is the difference between Single Responsibility Principle and Separation of Concerns?

+3  A: 

Single Responsibility states that an Object be responsible for a single unit of work.

Seperation of Concerns states that applications should be split in to modules whose functionalities overlap as little as possible.

Similar end results...slightly different applications.

Justin Niessner
what is the difference between the object and the module? For me a module is a class and a object is class or an instance of a class
Rookian
A Module can be an entire piece of similar functionality in an application...made up of the interaction between many classes (each class having a single responsibility if you're following the Single Responsibility patter).
Justin Niessner
+1  A: 

In my opinion Single Responsibility Principle is one of the tools/idioms to achieve Separation of Concerns.

BostonLogan
What? One could easily create an application which has non-overlapping functionality (SRP) that contains many objects which non-separate concerns (!SOC).
Andrew Song
But is is much harder to imaging an object that has multiple responsibilities and yet adheres to separation of concerns principle. In other words to achieve real separation of concerns (on all levels) one better observe single responsibility principle
BostonLogan
+1  A: 

Separation of Concerns is a process; the Single Responsibility Principle is a design / architecture philosophy. They're not completely disjoint, but they serve different purposes.

McWafflestix
+4  A: 

Single Responsibility Principle (SRP)- give each class just one reason to change; and “Reason to change” == “responsibility”. In example: Invoice class does not have a responsibility to print itself.

Separation of Concerns (since 1974). Concern == feature of system. Taking care of each of the concerns: for each one concern, other concerns are irrelevant. Hiding implementation of behavior.

From here.

luvieere

related questions