In an OO component, when you have only one implementation available for a class, and this class is not “published” to other components, is it still advisable to have an interface and work with the interface instead?
I am fully aware of the principle of designing "programming for the interface", and I also use it widely.
Recently, I have been observing that most of the time no other implementation is required (although this is possible and makes sense). As a result, always working with interfaces, the application code will have a sufficient number of interfaces with one implementation for each, and the interface seems like overhead.
Instead, is it preferable to work with a specific class and enter an interface only when a second implementation is required? In any case, currently extracting an interface using the IDE is a breeze. And when the new interface is introduced, references to the old concrete class can be changed to use the new interface instead.
What do you think?
source
share