Pergunta de entrevista da empresa Apriva

Describe not what an interface is, but why I would use them vs a base class.

Resposta da entrevista

Sigiloso

20 de ago. de 2015

I said that I didn't believe there was any benefit to doing an interface since you still had to write the methods and that there was no no reusability there. He explained it in a way I don't think I've heard before which I actually liked -- something like "It's more about defining what an object can do without bearing the burden of poor class cohesion and potential side effects of joining some other object's family." or something along those lines. He told me to think of inheritance as an "is a" and composition as "has a" and interfaces as "can do". I don't think I've ever heard it explained that way before which was interesting.