Skip to main content
1 of 4
Christophe
  • 80.6k
  • 11
  • 132
  • 199

Every class has an interface :

  • Interfaces may be explicit, like when classes implement some interface or conforms to some protocol;
  • Interfaces may be implicit: it's what a class defines top be visible from the outside and can be used, hiding the internals.

You might for example read a lot of advices about the use of interfaces and how to use them in patters in the GoF, but most of the code examples in that book are C++ code, sometimes with pure abstract classes (the C++ equivalent to interface), often, referring to an implicit class.

So you always need to think about an interface when you develop. The key is to see it as a black-box and not to rely on the concrete implementation you're writing for it. This is not overenginering. It's just OOP.

Some of these implicit interfaces may need to be reused for different classes. Sometimes unrelated. This is the moment when you go one step further.

Christophe
  • 80.6k
  • 11
  • 132
  • 199