Java数据结构建议
正在开发的应用程序的一部分是向用户呈现一个表单并请求他们拒绝/接受它。有三种类型的用户需要批准相同的表单才能被视为已接受。我需要的建议是这样的:我可以使用/最好使用什么结构来存储用户类型及其响应? 到目前为止,我有一个对象是 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
假设您有
在我工作的系统中,我们将用户与执行任务的角色解耦 - 高级人员有时会履行初级人员的角色。
Suppose that you have
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.
“非规范化”系统将具有
User
、UserType
枚举(或类似)以及User
=> 的集合。响应
。有地图就可以了;它可以加快速度,确保用户不会投票两次。如果您需要按
UserType
聚合答案,您可以单独记录UserType
=>响应
随着响应的统计而更新。A "de-normalized" system would have
User
s, aUserType
enum (or similar), and a collection ofUser
=>Response
s. 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 ofUserType
=>Response
s updated as responses are tallied.为用户创建一个基类。扩展它们以创建您自己的自定义用户类,例如审批者。在 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.