Sin categoría

Java Interfaces Code Decoupling

In this blog, I am going to talk about Interfaces and how it help us to decouple our code.

As the Hexagonal Architecture mentions, having our code decoupling, it makes it easy to maintain.

In this tutorial, we are going to create an example of how to use interfaces to build an application to send Emails. It won’t send an email, but you will have a perspective about the interfaces, that it is the main idea.

As we know, to send an email, we need the same information, (dest, email, co, coo, etc) no matter what email service we use. Imagine that you need to create an application to send Emails, you already use Gmail as your email service.

Then you create your code to send emails using Gmail but suddenly, your company changes the email service. So you already create an application to send Email using Gmail. It would be easier to change just the implementation of your code and not the business logic.

So we are going to use the next structure using Eclipse and Java.

Sin título.png

Continue reading