5 ms·
makes sense, thanks for the reply and clarification. although, how do you suggest to phrase it / to apply SRP in a language without interfaces e.g. Node.js? I
by christian_fei 6y ago
makes sense, thanks for the reply and clarification.
although, how do you suggest to phrase it / to apply SRP in a language without interfaces e.g. Node.js?
In my opinion it's more about coupling than interfaces.
I feel I'm quite in line with the following by unclebob, let me know what you think, i'm open to learn more
https://blog.cleancoder.com/uncle-bob/2014/05/08/SingleReponsibilityPrinciple.html https://blog.cleancoder.com/uncle-bob/2014/05/08/SingleRepon...
- compressedgas 6y agoThe interfaces don't have to have representation in the language for their existence. This is true for all programming constructs. They are patterns imposed by design that can exist without support from the language. A language does not need to have interfaces to have interfaces. An interface is simply a set of methods and the contracts those methods obey. An object can be said to implement an interface if it has the methods that obey the required contracts. Interfaces are entirely about decoupling. Such that the client of an interface depends on the contract of that interface and not any object that implements it. The SRP in SOLID is about factoring interfaces such that each client ends up with interfaces that are specific to its use of the object rather than depending on an interface that provides more than is needed. That is the interface is responsible to a single client. The example for SRP that is given is an interface that combines two distinct uses. By splitting those interfaces, the code that results is more flexible even if there is only one object that implements both interfaces. Neither of those SRP mentioned in that article are the specific SRP that appears in SOLID. Nothing wrong with that. Please cite Clean Code or that article, rather than SOLID, for them.
- bobly_today 6y agoUh have you heard of the interface segregation principle?
- adamkl 6y agoI think you are confusing SRP (Single Responsibility Principal [0]) with ISP (Interface Segregation Principal [1]). [0] https://en.m.wikipedia.org/wiki/Single-responsibility_principle https://en.m.wikipedia.org/wiki/Single-responsibility_princi... [1] https://en.m.wikipedia.org/wiki/Interface_segregation_principle https://en.m.wikipedia.org/wiki/Interface_segregation_princi...
- christian_fei 6y agoYES! Had my doubts!
- compressedgas 6y agoI think I did. They are so similar that I have mentally merged them as they are a symmetric pair. One is dual to the other.