My question here is quite straight as mentioned in the subject.
However, please allow me to give some brief explanation here about my innocent thoughts.
I've been using Axon for approximately 10 months now. I used to design my project structure based on the Hexagonal architecture with two top level packages respectively for domain
and infrastructure
.
Furthermore, domain
package will contain different domain objects (as explained in the DDD concept) such as follow:
Aggregate
(this will be an Axonaggregate
class).Repository
(in my case, this will be a Spring Data Repository interface).Entity
(in my case, this contains any lookup entity that i used for set-based consistency validation as written here).Service Port
(collection ofInput
andOuput
port interfaces).Commands
(representing AxonCommand
object).
As for Events
, I used to put them on a different module that I compiled as a jar
file, so I can share it to other developers whom going to use the same event in their project.
I've noticed recently that all of my commands and events were basically anemic models (an anti pattern that we should avoid). Is there any good practice on this ? Or, Is it something that intentionally used by design ?
I've been thinking to put my Command
classes within my Aggregate
class (as an inner classes). At least by using this approach I won't end-up with having so many anemic models scattered outside. Any thoughts ?