r/javascript • u/[deleted] • Jan 20 '20
SOLID: Interface Segregation Principle in JavaScript and TypeScript
https://medium.com/@carsten.behrens1/solid-interface-segregation-principle-in-javascript-and-typescript-e5a962e73aee
0
Upvotes
1
u/placek3000 Jan 21 '20
This article reminds me a banner where first letters are big and nicely written but the far you go they become more and more narrow to fit in the space that is left. And the end the author throws a sentence in you and gives no explanation or examples.
Personally I like to think about ISP in JS as a rule that encourages you to pass into functions only the data and methods that are needed by that functions. For example you shouldn't pass the whole `cat` object but only the `cat.body` field if all you want is to draw that animal on screen. The draw method doesn't need to know about the `cat.meow()` method or the `cat.name` field so there is no point in coupling the drawing function with those information and potentially encouraging people to use them making the whole code harder to refactor.