4 ms·
> Having an interface for a single implementation is just redundant. A class already has an interface - it's public API. Depends on the language. And sometime
by josteink 5y ago
> Having an interface for a single implementation is just redundant. A class already has an interface - it's public API.
Depends on the language.
And sometimes you want to enforce a public contract of any implementation (current and future).
Personally for me, the biggest gain I see when writing against interfaces is that any class which expects a interface is already prepared for test-doubles, as opposed to classes written against concrete implementations which may even be initialised internally. Then just even starting to write a test becomes a so much bigger task.
Of course, everything with moderation, sometimes even moderation itself ;)