N
N
nepster-web2017-07-18 16:50:48
PHP
nepster-web, 2017-07-18 16:50:48

Partial selection and entities?

All the examples that are on DDD, of course, are cool and all that, but when it comes to development, questions arise.
For example, we have an entity that can contain a collection of other entities.
For example: The Client entity , which can contain a collection of Training entities .
Sometimes there is a task when you need to get one specific workout in the context of the client - for example, on the page of a specific workout.
This is very easy to do by accessing the collection, looping through it and finding the desired entity, or by key.
However, why make a request and get all the workouts if you only need one?
We can also request 1 workout and put it in the collection, then it will be a partial object with incomplete data, which is not good (and the context is also violated).
In general, what to do in cases where a piece of data is needed in the context of an entity?
Well, specific questions
1. Is it possible in essence to contain methods, such as getTrainings() and getTraining($id) with lazy loading?
2. Doesn't it suggest the use of some temporary VOs that will be generated using the Services and will contain data for a specific working page?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Korobkov, 2017-07-18
@BorisKorobkov

Don't over complicate things unnecessarily. Need a specific training - get its object without any collections. Either by yourself (Training::findOne(['training_id' => $trainingId])), or through a client ($client->getTraining($trainingId))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question