I have a rich model, where e.g. one model
A depends on many related entities/value objects. Therefore we have methods in
A for retrieving collections of related objects:
getBars() and so on.
At one point, one or many of these related collections should not be fetched eagerly, and, moreover, should be fetched using pagination.
I do not want to 'pollute' the model with methods like
getFoosPage(from, to, size). This is not part of the business, it's part of the viewing problem.
How should I solve the pagination?
Next, sometimes I need to get just
Foos, but not
Bars. Should I have a method in my repo saying:
getAWithFoos()? I do not like that are returned
A will be only partially populated (no
boos), and you can not tell that just by inspecting the model.
For now, I am thinking in building a 'query' model, where I would have different classes for scenarios I need, like 'AWithFoos` that contains A and related Foos and so on. Does that make sense?