3 ms·
ISP is underrated. I think the problem is that the logical endpoint of ISP is that every interface has one method, which is unworkable in a classic OO language
by moomin 12y ago
ISP is underrated. I think the problem is that the logical endpoint of ISP is that every interface has one method, which is unworkable in a classic OO language. At this point you realize that what you really want is functions as parameters and move on with your life. :)
Not true if there are laws specifying the relationship between the methods. But way more often true than you'd expect from reading a (good) java codebase.
- SideburnsOfDoom 12y agoThe ISP is good, but you can derive it from SRP: The SRP says that things should have one responsibility, and the ISP says that Interfaces are things too. I saw some Java 8 recently. The automatic conversion from a lambda to an interface with one (compatible) method was interesting, but yeah, it points to the problem that what you sometimes really want is just a function.
- adwn 12y ago> it points to the problem that what you sometimes really want is just a function Interestingly, this fact has been known to procedural as well as functional programming proponents for decades (one of the few aspects on which they agree).
- platz 12y agoThe problem with SRP is it's hard to define what that "one reason" is exactly. http://sklivvz.com/posts/i-dont-love-the-single-responsibility-principle http://sklivvz.com/posts/i-dont-love-the-single-responsibili... > sometimes really want is just a function summed up nicely here: http://blog.ploeh.dk/2014/03/10/solid-the-next-step-is-functional/ http://blog.ploeh.dk/2014/03/10/solid-the-next-step-is-funct...
- regularfry 12y agoI find Uncle Bob's definition of SRP makes far more sense if you change it from "responsibility for something" to "responsibility to someone." That is, there should be one and only one person, or business role, who would want a given class to change. The "one reason" then becomes "That guy over there gave me a business justification for it," and nothing else really matters. It's just as easily read then as "a class cannot serve two masters."
- tel 12y agoThat matches well with the original guiding principles for software modularity: modules should encapsulate deferred or changing decisions, nothing more or less.
- platz 12y agoI think the point is you cannot predict what decisions are going to change or be deferred. That's why I like the interpretations of this that try to make change in any direction more reasonable. Otherwise you get people building things like abstract factories "just in case".
- tel 12y agoI think that's a little silly, or rather worded imprecisely. Freedom in all directions prohibits all structure, all implementation.
- SideburnsOfDoom 12y ago> The problem with SRP is it's hard to define what that "one reason" is exactly Sure it's hard to automate it. It's one of those subjective, experience-based factors that keep humans like me in a job. I never thought that it was a rule that can be mechanically applied.
- platz 12y agoSure, but there are other measures, and the coupling vs cohesion take at least provides a semblance of objectivity vs completely subjective.