B-JUG#16: Hexagonal Architecture in Theory and Practice

Gaining of knowledge

This week, I had the chance to attend B-JUG#16, an event focused on a topic I find very interesting: Hexagonal Architecture, also known as Ports and Adapters. The meeting was led by my colleague Dominik Kruk, who explained the theoretical basics and showed how to use this approach in a real project.

What is Hexagonal Architecture?

Hexagonal Architecture is a design pattern that separates business logic from external technologies. This brings many benefits:

  • The application becomes more flexible and easier to maintain.
  • Testing is faster because components don’t depend on external infrastructure.
  • Adding new technologies (e.g., changing the database or an API) requires fewer code changes.
  • Unit tests for business logic run much faster since they don’t need to load the full Spring context.

During the presentation, Dominik explained the concepts of ports (interfaces defining communication between the app and external systems) and adapters (implementations that connect the ports to specific technologies). He also prepared a demo project to show how this works in practice.

Dominik shared his experiences, pointing out the advantages and challenges of this pattern. A key question was: does Hexagonal Architecture really make software development easier, or does it add more complexity? As always, the answer depends on the project. There were many interesting questions, and the discussion after the presentation was very engaging.

In the second part of the event, Dominik showed code from a book rental demo project built with Hexagonal Architecture. This example demonstrated how easy it is to:

  • Replace one external API with another without changing the business logic.
  • Map responses from external APIs to internal objects, even if the API changes.

I found this part especially interesting because I am currently working on a project with a similar approach. Seeing how others use the same ideas gave me new inspiration for improving my own code.

One exciting moment during the event was the raffle. I was lucky to win a free license for IntelliJ IDEA, a tool that makes Java development much easier. I’m looking forward to using it in my projects – a one-year license will be very useful!

After the presentation, participants had time to exchange experiences and network during a coworking session. There was beer and tasty pizza, although I couldn’t enjoy it because I’m on a Keto diet. However, meetups like this are a great way to broaden your knowledge and get inspired by different coding approaches.

Finally, I’d like to thank the event sponsors, Britenet and JBrains, for making this meetup possible.

Leave a Reply

Your email address will not be published. Required fields are marked *