3 ms·
He wrote an entire section on why you shouldn’t return an interface and then gave a concrete example of an exception to the rule. It seems to me that it is inde
by DSingularity 2y ago
He wrote an entire section on why you shouldn’t return an interface and then gave a concrete example of an exception to the rule. It seems to me that it is indeed a valid exception.
- silisili 2y agoI don't disagree with the specific example given, but rather that because those cases exist, we blanket say it's not a bad idea to do so...if that makes sense. It's why I used 'almost' there. Perhaps it needed to be a little segregated. The initial section is written from the perspective of a library author, asking them not to nuke away types. The example seems more of a middleware/client side thing. More often than not of course it'll make more sense to deal with types at the base layer, and interfaces at the client layers, as that's the point of them, after all.