T
T
topuserman2020-07-05 19:35:22
OOP
topuserman, 2020-07-05 19:35:22

What entities or layers should an application of this format have?

It is required to develop a computer configurator.
We have a ready-made data structure in the database.

For starters, I'd like to have a separate entity for every part of the computer.

Here questions immediately arise:

Do I understand correctly that in the context of DDD - this is called Entity ?
I read in some sources that Entity just contains state. Those. this is one record from the database table, with all its properties (+ may contain some getters), and cannot contain any logic.

If so, what if the Entity is a computer Motherboard and I need a method that returns a list of all eligible Processors for that Motherboard.

Where then you need to place the method and implementation that will do this? And what will this layer be called in the context of DDD ? Repository ?

Further, the question arises, if I receive a list of Entity - is it a collection of this type of Entity ?

I would be grateful if someone breaks down this task into components (layers) and their names, with a few comments, who has what responsibility.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Korotenko, 2020-07-05
@firedragon

Motherboard.
it has components such as
processor
memory
hdd
Sdd
usb
and so on.
But !
Entity
is Motherboard
.
processor
memory
hdd
Sdd
And you are already creating a utility method in the repository.
GetCompatiblyCpu returns processors that are compatible with the mother.
And already at the level above, you assemble a model that contains all the offal.
The base should be simple.

M
Maxim, 2020-07-05
@myks92

1. DDD does not start from the base, but from the code.
2. Entity can be different. If you are talking about an anemic entity, then it has a set and a get. However, this is not considered good practice. It is more suitable for rapid development. Therefore, the essence must be rich. Ideally, only consist of modification methods, removing get and set. In this case, you can lay business rules directly in the entity. You said that it cannot consist of logic - this is erroneous. A good entity must have logic. Example
3. Entity returns nothing. This is the task of the repository.
4. In addition to Entity, there is an aggregate. Here it just includes all the details.
It is better to read or watch about DDD. Since this is a rather extensive topic, which needs to be understood not only by the answers on the toaster, but also in practice.
Article to help: https://m.habr.com/en/post/61524/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question