B
B
BonBon Slick2017-12-10 13:48:37
Software design
BonBon Slick, 2017-12-10 13:48:37

Entity vs Object Value?

I'm not quite sure what to use and when.
I take it that's one thing? Or is it possible to do both? And how right? When is it necessary? Why?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vova07, 2017-12-14
@BonBonSlick

Hello!
I'll try to be brief.
An entity is an object containing a set of data with a unique identifier. In addition to this simple rule, there is one more important thing: this object has a life cycle that can be described by behavioral methods.
Value Object is an object containing a set of data (immutable). Nothing guarantees uniqueness, they do not have a life cycle and do not contain behavioral methods, and most importantly, they are immutable.
And now let's try to answer your questions (I'm sorry for being rude, but they are slightly incorrect on this and the answers are not obvious):
It all depends on your context, domain and aggregate. There are simple aggregates that can only contain entities, if complex where both are used. There is no obvious answer, and no limitations.
You can use both or not use, the main thing is to keep the unit as simple and clear as possible.
That's right, the concept is loose and, as I said, everything depends on the aggregate that you write, on the context that you model, and on the business logic that is in your domain. Use whatever suits your needs.
Same here, there is no right answer. It is necessary when your business logic starts to work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question