Some people say that interfaces are useless. Actually, I hear it in my current job (a lot). Some of my teammates kind of hate interfaces… I’m not joking. Whenever they see interfaces in my code, some of them start summoning a battery of arguments against them… they think interfaces are useless or unnecessary.
I don’t believe that, but I won’t deny that some of their arguments are interesting. I will try to introduce some of them, and then I will try to explain the reason why I don’t think interfaces are useless and, even more, they are very important.
IMHO, this is what you should do with interfaces:
Suppose that we make a REST call to an external system and it gives us a flat Customer in JSON format, then we want to transform that Customer into one of our own model.
Then, we create a Transformer interface with one method transform that receives a Data Transfer Object (DTO) and returns a Model Object.
#java #software-architecture #software-engineering #object-oriented-design #interfaces