Of course you don't have to implement domain logic inside of the gateway.
Bu I tried with a lot of success an interesting separation in my
last/current project.
Instead of keeping the Gateway especially dump so that it can be
reimplemented, I went down a different road:
+---------+ +---------+ +---------+
-Entity-> | Gateway | -E-> | Marshal | -DTO-> | Backend |
+---------+ +---------+ +---------+
+---------+ +---------+ +---------+
<-Entity- | Gateway | <-E- | Marshal | <-DTO- | Backend |
+---------+ +---------+ +---------+
So, the Gateway holds an injected Marshal and an injected Backend. The
Marshal resides somewhere in the domain world. He is specifically
responsible for transforming known Entities in storable DTO and vice-versa.
The Backend is a interface which only operates on the DTO, no Entities
are involved here.
By this approach, you "push-down" the stupid simplicity of persistence
into a Backend implementation. The Gateway can now hold a very very low
amount of business-related information.
I had some situations where domain-agnostic gateways felt very stupid.
This is one of the solutions I came up with.
We tried another approach by encapsulating the Gateway in a
Domain-Service which encapsulated specific behavioural facts around
storage and such.
WDYT?
>> mail
h...@jakob.io <javascript:>
>> page
http://jakob.io