Java数据结构建议

发布于 2024-12-21 01:06:27 字数 306 浏览 0 评论 0原文

正在开发的应用程序的一部分是向用户呈现一个表单并请求他们拒绝/接受它。有三种类型的用户需要批准相同的表单才能被视为已接受。我需要的建议是这样的:我可以使用/最好使用什么结构来存储用户类型及其响应? 到目前为止,我有一个对象是 Approvers。这包含三种类型的用户以及 setter 和 getter(以及与操作相关的其他方法)。我还创建了另一个对象 UserDecisions,其中我有两个属性要设置,它们是:Usertype 和 UserDecisions。回复。但我想不出如何将它们联系在一起,或者是否有更好的方法? 谢谢,

我考虑过的是 2D 数组和 2D 数组。哈希图。

part of the application am developing is presenting a form to the user and requesting them to either decline it/accept it. There are thee types of users that will need to approve the same form so that it is considered accepted. The suggestion I need is this: What structure can I use/best use to store the user type and their response?
So far I have an object that is Approvers. This holds the three types of users with setters and getters (and other methods related to operations). I also created another object that is UserDecisions where i have two attributes to set, they are: Usertype & response. But I can't think of how to link them together or if there is a better way altogether?
Thanks,

P.s. things i've considered were 2D arrays & hashmaps.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

乖乖 2024-12-28 01:06:27

假设您有

User { name, type  }  
         // type is perhaps an enum with values such as administrator,
         // manager, seniorManager, executive 

Response { user, decision }
         // decision is an enum "pending", "approved", "rejected"

Role { name, minimumTypeOfUser }
         // first approval can be done by administrators or above
         // second approval by managers or above
         // third approval by executives only

Approval { Role, Response }


ThingToBeApproved { detalsOfWhatNeedsApproving, approvalList<Approval> }
          // when you set up the approval list you specify each
          // approval role and then select a user whose type matches
          // the role.

在我工作的系统中,我们将用户与执行任务的角色解耦 - 高级人员有时会履行初级人员的角色。

Suppose that you have

User { name, type  }  
         // type is perhaps an enum with values such as administrator,
         // manager, seniorManager, executive 

Response { user, decision }
         // decision is an enum "pending", "approved", "rejected"

Role { name, minimumTypeOfUser }
         // first approval can be done by administrators or above
         // second approval by managers or above
         // third approval by executives only

Approval { Role, Response }


ThingToBeApproved { detalsOfWhatNeedsApproving, approvalList<Approval> }
          // when you set up the approval list you specify each
          // approval role and then select a user whose type matches
          // the role.

In systems I work we decouple the Users from the Roles for doing a task - a more senior person on occasion fulfils the junior's role.

肩上的翅膀 2024-12-28 01:06:27

“非规范化”系统将具有 UserUserType 枚举(或类似)以及 User => 的集合。 响应。有地图就可以了;它可以加快速度,确保用户不会投票两次。

如果您需要按 UserType 聚合答案,您可以单独记录 UserType => 响应随着响应的统计而更新。

A "de-normalized" system would have Users, a UserType enum (or similar), and a collection of User => Responses. A map is fine; it speeds up making sure a user doesn't vote twice.

If you need to aggregate answers by UserType you could keep a separate tally of UserType => Responses updated as responses are tallied.

忆悲凉 2024-12-28 01:06:27

为用户创建一个基类。扩展它们以创建您自己的自定义用户类,例如审批者。在 UserDecisions 类中,创建一个 formName 或 userName 字段,它将 UserDecisions 与 Users 链接起来。或者您可以创建一个单独的类用于链接目的。

Create a base class for Users. Extend them to create your own customized user class such as Approvers. In UserDecisions Class, create a filed for formName or userName which will link UserDecisions with Users. Or you can create a seperate class for linking purpose.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文