Answer the question
In order to leave comments, you need to log in
How to organize a factory to create objects?
In the process of studying DDD, I will immediately say that I do not use ORM. There are the following entities:
UserService, User(Entity),Group(Entity),Address(ValueObject)
To get a user with connections, I do something like this:
class UserService{
function findByid($id){
$User = $this->UserRepository->find($id);
$Group = $this->GroupRepository->find($User->getGroupId());
$User->setGroup( $Group ) ;
$User->setAddress(new Address( $User->getCity(), $User->getStreet() ));
return $User;
}
}
Answer the question
In order to leave comments, you need to log in
I’ll say right away I don’t use ORM
The repository (DDD) must return READY objects (in DDD aggregates). How he collects them, himself or delegates a dozen finely chopped factories, whether he uses ORM or not, this is the tenth matter. In general, I recommend double-checking your understanding of the basic ideas of DDD.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question