开发者

What dataclasses should I create in a 3-tier project?

开发者 https://www.devze.com 2023-01-11 22:34 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消