Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have two model classes User and Role and two managers/DAOs (UserManager and RoleManager) plus a method which gives me all users with a certain role (List<User> getUsersWithRole(Role)).

In which manager does this method belong and why?

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

Since you are expecting a list of Users from the getUsersWithRole(Role) method it belongs in the UserManager.

You a making a query for Users (which are handled by UserManager), just with a filter on their Role.

share|improve this answer
    
I tend to agree but that eventually turns UserManager into a god class of sorts because almost every object in my model has a relation to User. –  Aaron Digulla Dec 9 '11 at 15:13
    
I don't see your point. All those objects having a relation with User don't need to know about UserManager, or vice versa. Only those that spawn new instances (via the manager) need to know about the manager, and the manager should be there only to spawn, safe or remove Users. If you have a method for every query you might end up with a big class, but in my opinion that would be appropriate. –  Stim Dec 9 '11 at 15:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.