Re:Interfaces Generally Belong with Users
by _ZeD_ on Sunday November 24, 2019 @12:43AM
(#21618641)
BTW:
>>> the obvious thing is to do in a nominally typed language like Java or C++ is the "extract interface" refactoring, where you create an interface [...]
well, first of all, I still think that a library (even an internal one) should expose only interfaces by definition.
It's not only for the sake of the tests, it's also because it forces to keep boundaries "clean".
and by second... what I normally use is to trow in mockito[0] and let it do the subclassing, instantiation and definition of custom methods in 2-3 lines...
>>> the obvious thing is to do in a nominally typed language like Java or C++ is the "extract interface" refactoring, where you create an interface [...]
well, first of all, I still think that a library (even an internal one) should expose only interfaces by definition. It's not only for the sake of the tests, it's also because it forces to keep boundaries "clean".
and by second... what I normally use is to trow in mockito[0] and let it do the subclassing, instantiation and definition of custom methods in 2-3 lines...
[0] https://site.mockito.org/
I'm not sure that "make it easier to define interface <a posteriori>" it's a good selling point to structural typing