I\'am unclear as to what the roles and responsibility of the factory class is. I know enough that the factory class should be resposible for the creation of domain objects (agg
The difference between a repository and a factory is that a repository represents an abstract persistent storage, while a factory is responsible for building an object.
So, for example, let's say I'm registering a user. I'll get my user object from a factory
IUser user = userFactory.Create(name, email);
Then pass it to the repository, which will be responsible for dealing with it.
userRepository.Insert(user);
Factories in DDD can be thought of as a way to hide new, an abstraction of the details of instantiation. It allows you to very effectively program to an interface rather than a concrete.
In addition, this allows repositories to be focused on their entity type, and thus the use of generics becomes very powerful.