top | item 23919350

(no title)

rickmode | 5 years ago

I had this same belief but there is one other useful situation where an interface plus just one implementation class helps, and that's when you want to hide the noise of implementation details from another part of the program.

This can happen between different layers of app. For example you might have a persistence layer under an API or UI, and want to expose a nice "clean" interface to the API / UI layer.

discuss

order

Const-me|5 years ago

Yes.

To add to that, in C++ that approach often saves non-trivial amount of compilation time. Consumers of the object only need to #include the interface, while the implementation of the object, both code and data, stays private and is not needed to compile the consuming code.