3 ms·
I hate this pattern. Needless indirection for insignificant benefit.
by tormeh 3y ago
I hate this pattern. Needless indirection for insignificant benefit.
- bb88 3y agoGolang "punishes" you for wanting to write a unit test around code. You need to refactor it to use an interface just to unit test it.
- sidlls 3y agoNo, you don’t, unless you’re of the opinion that actual data structures with test data should not be used in a unit test.
- bb88 3y agoI think you're missing the point here. Duck typing with python (e.g.) makes it easy to mock a class. One can subclass a Java class to make a mock, etc. One can't do that in golang unless it's through an interface which then decouples tightly coupled code because [golang reasons].
- akoboldfrying 3y agoIt's indeed horrible when debugging. OTOH, there's merit to the idea that better testing means less overall time spent (on either testing or debugging), so design choices that make testing easier provide a gain -- provided that good tests are actually implemented.