Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个名为 的关联类Role,如下所示:
Role
我以前没有真正使用过关联类,所以我不得不问:这是正确的使用它吗?这个想法是每个人在每个组中都有特定的角色,而每个组也知道与他们相关的人。
尽管我理解了原理,但我不知道如何实际实现它。
我认为直接的实现是让关联类(为清楚起见我将其命名GroupMembership)包含
GroupMembership
isAdmin
该类Person包含对GroupMembership对象的引用列表,描述了该人所属的组。
Person
该类Group还包含对GroupMembership对象的引用列表,为您提供有关组成员的信息。
Group