Java – repository classes in DDD
I'm trying to focus on DDD. I have a question class and a feedback class (etc.) I want to be able to count the number of problems, the number of feedback, and many other things that are considered meta operations
Should such "meta" methods be located in the same repository as other methods belonging to the class, or should they be located in the metarepository where you use different meta methods to query the database (in this case, all classes will be mixed)?
Solution
Nothing in DDD prohibits the use of multiple repositories per aggregation You can simply create a repository for basic queries and lifecycle methods (iquestionsrepository) and a separate repository (iquestionsstatistics) for what you call "meta" or "statistical" purposes This applies to larger domains, where following the one repository per aggregate principle may lead to "method explosion" and SRP violations Basic OOP principles should not be violated after DDD