1
0 Comments

Mapping in DDD and clean code

I was introduced to real DDD through work and 9 months ago, I asked why the objects/entities/models/DTO's were mapped that much and didn't got a good response.

I thought it was nuts mapping the same model over and over again.

With my side project, I'm also implementing DDD with events.

I also use AggregateRoot which , at work, isnt used for domain events. But I'm using it now after-hours.

Today, it became clear why models are mapped that many times.

The Entities in the core layer contain AggregateRoot, which contains the events property that had a list of all the DomainEvents that were triggered.

I wasn't too happy when I saw them also getting returned from my API, since I returned the core entities.

The rest was already clear ( eg. Seperate the database models from my core entities), but such a minor thing today was quite an eye opener.

on May 24, 2020