What exactly is “interface based programming”?

It’s basically a matter of expressing your dependencies in terms of interfaces instead of concrete classes (or worse, static methods). So if one of your classes needs to perform authentication, it should be provided an IAuthenticator (or whatever).

This means that:

  • You can write your code before implementing the real dependency
  • You can test via mocking really easily (without having to mock classes, which gets ugly)
  • It’s clear what you depend on in terms of the API instead of implementation (i.e. you have looser coupling)

Leave a Comment