What are entities?

Hi,

beginner here. I would like to ask for a specification what is actually considered an Entity and also what is NOT considered an Entity in the context of Axon Framework 3.0. I could not find this described anywhere.

Thanks,
Áron

Hi Áron,

Where possible, Axon uses the terminology defined by DDD. In that sense, an Entity is a building block in a model that maintains state of a certain concept. In Axon, (or more generally, in CQRS), you can find Entities on both the Command and the Query side.

The description given by Domain Driven Design is a good starting point. Paul Rayner has written a nice post about Entities and Aggregates (both very important concepts in Axon): http://thepaulrayner.com/blog/aggregates-and-entities-in-domain-driven-design/

Cheers,

Allard

Hi,

thanks for the answer, but I am sorry, I tried to read that post (in fact I read it, it just doesn’t really make sense to me because of the heavy use of terminology), and it tries to answer my question from a different angle then from I would understand it.
What I am curious about, what is the datastructure that at any point it’s evolution might be called an Entity? What are the necessary features that it has to possess so it is acceptable to be called Entity?

However your link did raise another issue for me. How would one go and create an admin interface where an end user would be able to create on the fly new kinds of Aggregates?

Regards,
Áron

Hi Aaron,

Image a Person class with 3 properties: id, name and clothes.
The fact that we use an “id” here, already tells us that we can change some properties, but still recognize it as the same person. So we can change the name, or (more realistically) changes that person’s clothes. It’s still the same person.

Imagine money. If you have a 10 euro bill, and another one, you don’t really care which is which. As long as the properties “10” and “euro” are there, they are identical to you, and probably also the shop owner. That makes this bill (in your context) a value object. The “identification” is done using the properties, which therefore can’t change.

In software, this makes value objects very powerful to use. You can create as many (or as few) instances as you like. Value objects are inherently thread safe (because they’re immutable). Entities, on the other hand, can change state and must be properly safeguarded against unwanted (concurrent) mutations.

Hope this helps.
Cheers,

Allard

PS. I can recommend reading the DDD chapters on these building blocks. If you can’t get a hold of the DDD book by Evans, check out the DDD Quickly minibook by InfoQ: https://www.infoq.com/minibooks/domain-driven-design-quickly

Thanks Allard, this cleared up a lot of confusion I had.

However the situation that made me ask my second question is making me anxious more and more, so I have to ask again, maybe someone can help with it:

  • How to create new kinds of Entities and Aggregates on the fly, programmatically, using Axon Framework, without need to create, compile and deploy new files?

Thanks,
Áron

Hi Áron,

Axon isn’t designed to create aggregates on the fly. At least not the aggregate types (as in classes). On the other hand, components are stimulated to be location transparent, meaning that you should be able to replace a component with another (version) transparently if they are deployed separately.

Cheers,

Allard