DDD Part 3: Domain-Driven Design and the Hexagonal Architecture for Java Applications

Domain-Driven Design and hexagonal architecture

This is the third part of our in-depth series on Domain-Driven Design (DDD). Part one discussed strategic domain-driven design, and part two discussed tactical domain-driven design. Updated for 2024.

In this article, we'll take a look at how to turn a domain model into working software - specifically, how to use the hexagonal architecture. The previous two articles were pretty generic, even though the code examples were written in Java. Although a lot of the theory in this article can also be applied in other environments and languages as well, I have explicitly written it with Java and Vaadin in mind.

Again, the content is based on the books Domain-Driven Design: Tackling Complexity in the Heart of Software by Eric Evans and Implementing Domain-Driven Design by Vaughn Vernon. I highly recommend you read both of them. However, even though I presented my thoughts, ideas, and experiences in the previous articles, this one is even more strongly colored by my thoughts and beliefs. That said, the books of Evans and Vernon got me started with DDD in the first place, and I’d like to think that what I’m writing here is not too far from what you will find in the books.

This is the second version of this article. In the first one, I got the concept of ports wrong. This was pointed out in a comment by a reader, which I am very grateful for. I have now corrected this error and updated the examples and diagrams accordingly. Comments about my interpretations of this architectural style and DDD are always welcome.

Subscribe to our newsletter

Be the first to learn about new Vaadin resources and tips

Learn about strategic domain-driven design in this blog series.

DDD Part 1: Strategic Domain-Driven Design

This is the first part of our in-depth series on Domain-Driven Design (DDD). Part two discusses tactical DDD, whereas, in part three, you'll learn how to apply DDD to working software using Java and Vaadin. Updated for 2024. Domain-Driven Design (DDD) has been around since Eric Evans published his ...
What is tactical domain-driven design

DDD Part 2: Tactical Domain-Driven Design

This is the second part of our in-depth series on Domain-Driven Design (DDD). Part one discussed strategic domain-driven design, whereas, in part three, you'll learn how to apply domain-driven design to working software using Java and Vaadin. Updated for 2024. In this article, we are going to learn ...

Designing REST APIs

Introduction If I had to guess, I would say that most Vaadin applications are self-contained, with the UI and the business logic packaged inside the same application archive and running inside the same Java virtual machine (VM). However, there are cases where it makes more sense to separate the UI ...

A Hybrid Approach to Spring Security in Vaadin Applications

In my previous blog post about Spring Security, I wrote about filter-based security and how to use that in your Vaadin applications. In this blog post, we are going to look at another way of utilizing Spring Security. In addition to filters, Spring Security has other ways of protecting your ...

Filter based Spring Security in Vaadin applications

Spring Security’s web infrastructure is completely based on standard servlet filters. All requests go through a filter chain, where each filter does something with the request and decides whether to continue down the chain or stop and do something else. For example, a filter could check if the user ...

Let's talk about DDD

All software systems are hopefully designed to solve a real world problem. To be able to do this, the software needs an abstraction of the problem - a model - that it can work with. Coming up with this model is not always easy, especially if the real world problem is complex. Domain Driven Design ...

Is MVP a Best Practice?

When I first learned about the Model-View-Presenter (MVP) pattern, I was excited. I thought this was The Pattern to use for Vaadin user interfaces and that it would make everybody’s life a lot easier. Now, when I am older and maybe a bit wiser, I am not so sure anymore. As an architect, it is easy ...

Spring Time for Vaadin

Originally, the idea of the webinar was to show you how Spring has been used in different Vaadin projects in the past. However, once Josh Long from Pivotal got involved, we ended up creating a first prototype of a completely new integration that will sweep the floor with the conventional ways. This ...