I have a relatively small project and I'm using a 3 tier architecture. Now I'm thinking about on how to split up some of the fu开发者_Go百科nctions in different data classes.
For example I have a User class and a Group class. My User class has a User.GetGroups function and my Group class has a Group.GetUsers function. Would I put the first in the UserData class as UserData.GetGroups or in GroupData.GetGroupsForUser or perhaps a completely separate UserGoupData class?
Why not do both of your suggestions? Regarding GroupData.GetGroupsForUser: just the phrase "ForUser" makes me think "if it's for the user, why not put it on the user object?"
I would just do User.Groups, and Group.Users. I think both of your examples make sense.
精彩评论