What is the difference between Single Responsibility Principle and Separation of Concerns?
SRP and SOC work on different level of abstraction. The purpose is in both cases to reduce the coupling and strengthen the cohesion. While SRP works more on an object level, SOC may also work on the implementation of function level. A function can be implemented by one object but also by several objects. Therefore the coupling and the cohesion of both principles may differ.
The Single Responsibility Principle and Separation of Concerns are really the same thing.
Sure you can get bogged down in an academic discussion trying to tease out some kind of difference between the two, but why? For all intents and purposes they describe the same thing. The biggest problem is people get so caught up in wanting to know exactly what a "concern" and "responsibility" are, that they perhaps miss the important idea behind SRP and SoC.
That idea is simply to split your codebase into loosely coupled isolated parts. This allows multiple developers to work on different parts without affecting each other, it also allows a single developer to modify one isolated part without breaking another.
This is applied at the module level, eg MVC is an architectural pattern promoting SRP and SoC. The codebase is split out into isolated models, views and controllers. That way the modification of a view can be done independently of a model. Two two aren't horrifically intertwined.
At a lower level this should be applied to classes too. Instead of putting dozens of methods in a single class, split the code out into several. For the same reasons.
Also even at a method level, split large methods out into smaller methods.
In principle. SRP is a principle, not a rule, so you don't have to (read: can't/shouldn't) follow it religiously to the extreme. It doesn't mean going too far and having only one seven line method in each class for example. It just means a general principle of splitting out code into isolated parts. The point is it will lead to a better codebase and more stable software.
Separation of concerns (SoC). Divide your application into distinct features with as little overlap in functionality as possible. (Microsoft).
“Concern” = “distinct feature” = “distinct section”
“Concern” works at both high and low levels
Single responsibility principle states that every module or class should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility. (Wikipedia definition)
“Responsibility” = “reason to change” change what? “a single part of the functionality provided by the software” = Basic Unit
Conclusion
Single Responsibility Principle works on basic units -> works at low level
Separation of Concerns works at both high and low levels
SRP and SoC work together for separation of concerns. They are
exactly the same at low level
Since none of the previous answers quote Robert Martin, who created the Single Responsibility Principle, I think a more authoritative answer is needed here.
Martin's inspiration for the SRP was drawn from David Parnas, Edsger Dijkstra (who coined the term Separation of Concerns) and Larry Constantine (who coined the terms Coupling and Cohesion). Martin consolidated their ideas into the SRP.
Another wording for the Single Responsibility Principle is:
Gather together the things that change for the same reasons. Separate those things that change for different reasons.
If you think about this you’ll realize that this is just another way to define cohesion and coupling. We want to increase the cohesion between things that change for the same reasons, and we want to decrease the coupling between those things that change for different reasons.
However, as you think about this principle, remember that the reasons for change are people. It is people who request changes. And you don’t want to confuse those people, or yourself, by mixing together the code that many different people care about for different reasons.
To the original question, the minor difference between the SRP and SoC is that Martin refined the term concerns to refer to people.
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.
Similar but: SoC is related to concerns: to break down a complex problem into several concerns, SRP is to have just one responsibility.