3 ms·
The trouble with implicit interfaces is maintainability: suppose Awesome gets a func PerformAwesomeness() added to it: what then happens to the code that thinks
by MaysonL 13y ago
The trouble with implicit interfaces is maintainability: suppose Awesome gets a func PerformAwesomeness() added to it: what then happens to the code that thinks myType is Awesome?
Not too bad when it's all in one source file, but get a few megabytes of code spread through a few thousand source files, and you've got a formula for chaos and heartburn.
- thrownaway2424 13y agoNot sure what you are getting at. If you add something to the interface of Awesome, then any call site which passes a thing not having a PerformAwesomeness() method will fail to compile.
- danieldk 13y agoUnless you rely on introspection, which happens a lot when your language does not support generics.
- NateDad 13y agoNo, it really doesn't happen a lot. If it does, you're doing it wrong.
- danieldk 13y agoIf you don't have parametric polymorphism, you only have two options to implement new containers: a new implementation for each type or using interface{}. The first leads to a lot of duplicate code, the latter requires you to use introspection to use safely. So, it does happen a lot, or you are making duplicate code.
- NateDad 13y agoOr you just don't need polymorphic containers that often (other than the ones that go already gives you).
- MaysonL 13y agoWhich means that every time you change an interface you have to compile everything (given that you don't explicitly call out the Awesome interface anywhere, so you don't know whether any particular source file will require the Awesome interface without compiling it).