B
B
BonBon Slick2020-12-26 05:43:32
Software design
BonBon Slick, 2020-12-26 05:43:32

Is it possible to store a Value Object inside a Value Objecta?

We consider VO in the context of DDD architectures.
For example, the entity User has a VO Address and it has a VO House in which the fields are apartment and floor.
The first thing that comes to mind is that this cannot be done. to update the Home, you must also delete the parent VO.

What principles are violated?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2020-12-26
@BonBonSlick

You are confusing two terms. As I understand it, you are contrasting ValueObject and Entity from DDD here.
ValueObject is some value that does not exist by itself in the domain. (eg address). For ValueObject , usually, they do not have a separate table in the database.
Entity is some model of a domain object (for example, a building)
For example, an address and a building:
An address consists of a street name and a house number. The street name and house number are also ValueObjects.
The building has some identifier and a set of attributes, which can be links to other entities, or values ​​- for example, the same address.
And now for your example:

VO Address and it has a VO House in which the fields are an apartment and a floor.

That is, it turns out
Пользователь:
- Адрес:
- - Дом:
- - - Квартира
- - - Этаж

Personally, it seems to me that this is the wrong hierarchy. It would be better to make a flat structure.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question