4 ms·
The purpose of a principle is to be understood, and help us write better software with that understanding. The fact that SPR is so widely misunderstood, then, i
by klodolph 5y ago
The purpose of a principle is to be understood, and help us write better software with that understanding. The fact that SPR is so widely misunderstood, then, is a failure of SRP as a useful concept, not a failure of people misusing the term.
Ideally, you take a term or phrase like "single responsibility principle" and use it to discuss a particular design, interface, or implementation. If you can't do that, you have to find a different way to discuss your code.
It's like "clean code". Most people will agree that code should be "clean", but not come to any sort of agreement about what makes code "clean," or whether some specific code is "clean." The way to dig yourself out is to ban the word "clean" and ask people to explain things using different terms.
You've used one of my favorite phrases to describe code... "hard to read and understand". It is, of course, subjective. Alice may think it is easy to read and understand, Bob may think it is hard. However, it's easy enough to agree, in most cases, that everyone on the team should be able to understand the code. Therefore if I find the code hard to read and understand, that's a valid criticism of the code, even though it's a subjective criticism.
I can say, "This code is hard to understand because there's a bunch of color scheme information mixed in with the tax rate calculations." Or I can say, "This code is hard to understand because there are too many small functions." Honestly, just throw SRP in the garbage.
- marcosdumay 5y agoHum, no. The purpose of a principle is that if you follow it you will very likely get a good result. Being easy to understand is nowhere on it. Why is it that everything must be dumbed down? If thousands of people can't get the principle, but it gets good results to the people that understand it, it is a good principle, and those thousands of people either study a bit or decide to live with their worsened condition. If you take the GP's single paragraph that explains the principle and tries to use it to discuss a particular design, you will see that it's perfectly possible. The fact that people can't do the same if they read a paragraph less and stop at the name is not very relevant.
- klodolph 5y ago> Hum, no. The purpose of a principle is that if you follow it you will very likely get a good result. If you can't communicate the principle, then it's not a principle any more. It's just personal judgement. It's "tacit knowledge". https://en.wikipedia.org/wiki/Tacit_knowledge https://en.wikipedia.org/wiki/Tacit_knowledge Principles are the opposite of tacit knowledge, they are explicit knowledge. > Being easy to understand is nowhere on it. I don't understand what this sentence means. I don't know how to parse "on" in this context and it's unclear what "it" is. > Why is it that everything must be dumbed down? Are you saying that "easy to understand" means "dumbed down"? If that's what you're saying, I don't agree with that. > If you take the GP's single paragraph that explains the principle and tries to use it to discuss a particular design, you will see that it's perfectly possible. The fact that people can't do the same if they read a paragraph less and stop at the name is not very relevant. The paragraph was vague. The problem is that the SRP does not help you communicate problems with code. It does not help you understand problems with code. It is too vague. Following SRP does not help you write good code, IMO.
- marcosdumay 5y agoJust to be clear. The thread is about an academic paper about the thing, from the 70's. And you are calling it tacit knowledge?
- frozenlettuce 5y agoprogramming advice feels like reading management books: people with experience try to put into paper their gut feeling, after years of empirical experience... and the end result is, at best, not very scientific. At worst, is outright misleading for beginners (as they lack experience to judge when said advice is applicable)
- Jtsummers 5y agoThis is why everyone learning to program should start with a language like an early BASIC with limited structured programming capabilities, no real use of subroutines (goto all the things), only global scope for variables, and no modules. Suffer a bit, then you'll appreciate things like SRP and structured programming a lot more.