The Single Responsibility Principle states that each module in a system should be responsible for a single feature or functionality, or aggregation of cohesive functionality. Another common way to put it is to say that each module should have only one reason to change.

learn more… | top users | synonyms (1)

33
votes
6answers
3k views

How do I prove or disprove “god” objects are wrong?

Problem Summary: Long story short, I inherited a code base and a development team I am not allowed to replace and the use of God Objects is a big issue. Going forward, I want to have us re-factor ...
40
votes
6answers
8k views

Single Responsibility Principle - How Can I Avoid Code Fragmentation?

I'm working on a team where the team leader is a virulent advocate of SOLID development principles. However, he lacks a lot of experience in getting complex software out of the door. We have a ...
8
votes
6answers
886 views

What are the practical ways to implement the SRP?

Simply what are the practical techniques people use to check if a class violates the single responsibility principle? I know that a class should have only one reason to change, but that sentence is ...
9
votes
4answers
2k views

How to determine if class meets single responsibility principle?

Single Responsibility Principle is based on high cohesion principle. The difference between the two is that highly cohesive classes feature a set of responsibilities that are strongly related, while ...
22
votes
8answers
2k views

What is the real responsibility of a class?

I keep wondering if it is legitimate to use verbs that are based on nouns in OOP. I came across this brilliant article, though I still disagree with the point it makes. To explain the problem a bit ...
13
votes
5answers
849 views

Is SRP (Single Responsibility Principle) objective?

Consider two UI designers who want to design "user attractive" designs. "User attraction" is a concept that is not objective and only resides in the mind of designers. Thus designer A could for ...
18
votes
10answers
2k views

Can/should the Single Responsibility Principle be applied to new code?

The principle is defined as modules having one reason to change. My question is, surely these reasons to change are not known until the code actually starts to change?? Pretty much every piece of code ...
8
votes
3answers
1k views

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

a)What is the difference between SRP and SoC? Perhaps that SRP is applied at class level, while SoC can be applied at system, subsystem, module, class or function levels. b) If answer to a) is yes, ...
5
votes
3answers
506 views

OO - are large classes acceptable? [duplicate]

Despite many years in IT, I still struggle with OO design. One particular problem I seem to keep ending up with is large classes, often containing many hundreds of lines of code. The OO world talks a ...
2
votes
2answers
246 views

Single responsibility vs procedural programming

Single responsibility (from SOLID) is like making me create classes with only one public method. But if it's so, it would be possible use static methods, and go back to procedural programming. What's ...