by Yhippa · 4y ago · 0 comments
Along comes a need for a second implementation years later. Now you have to figure out how to match the interface but also do some serious refactoring to truly make the interface more generalizable.
It is easy to say that doing it up front to genericize functionality in an interface but in practice I've seen that it's difficult to do right. When I create a new interface I hope that I did my best job with abstraction and that I give the least amount of rework to future developers.
It's a bit of a balance. Decoupling can definitely be taken too far. Anyone who has worked in the language has no doubt encountered the ravioli code left by someone who has just read Clean Code and has fully embraced Uncle Bob as their lord and savior.
In the end the need for this interface-as-decoupling pattern has dropped significantly with modern dependency injection and ad-hoc mocking libraries like Mockito. They grant most the benefits of these single-child interfaces with virtually none of the drawbacks.
But those whole years compilation speed benefited greatly (because in Java interface is a cutoff for incremental compilation - in Java interface is THE developer experience).