5 ms·
You can do that with classes -- as long the dependents don't instantiate their dependencies directly. However, I personally like interfaces (well, traits, I'm
by Quekid5 7y ago
You can do that with classes -- as long the dependents don't instantiate their dependencies directly.
However, I personally like interfaces (well, traits, I'm doing scala), because it makes it much easier for readers to understand what bits are supposed to be part of the interface and which parts are supposed to be an internal implementation detail. Without interfaces it's really easy to accidentally change e.g. a return type into a more concrete one which accidentally leaks impl. details and suddenly other bits of code will come to rely on those impl. details. I work on rather large/complicated systems and I've seen this gradual spaghettification time and time again.
Disclosure: I'm usually the person who gets called in to fix the mess -- so that might bias my perceptions here.