用于用户登录的UML类图 [英] UML Class Diagram for User Login

查看:7571
本文介绍了用于用户登录的UML类图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下图是我第一次尝试创建描述用户登录到网站的UML类图。

The diagram below is my very first attempt at creating a UML class diagram describing a user login into a website.

我确定它的设计不好,缺点很多,但是我希望从你那里学习如何设计一个简单的登录。我对您使用设计模式以及您将要使用的模式,如何在设计中实现它以及为什么特别感兴趣。

I'm sure its a poor design and full of flaws, but I'm hoping to learn from you guys how you would design a simple login like this. I'm particularly interested in your use of design patterns and which patterns you would use, how you would implement it in the design, and why.

任何建议,批评,意见和建议将非常感激。感谢提前。

Any advise, criticisms, comments and suggestions will be really appreciated. Thanks in advance.

推荐答案

这是我们如何实现这个功能

Here is how we implement this funcionallity

如你所见,我们有很多应用程序(这里,它的行为像你的网站)。

As you can see, we have many Application (Here, it behaves like your website).

主持人,WebMaster和会员,如您的映射所示,它将作为一个角色更好。无论您需要添加新的角色,都会发生什么。也许你必须改变你的所有模型。

Moderator, WebMaster and Member, as shown in your mapping, it would be better as a Role. What happens whether you need to add a new "Role". Maybe you have to change all of your model.

每个UserApplication(UserWebsite)都有其开始和结束日期。每个应用程序都有自己的角色。银行网站需要经理角色。健康保险公司网站需要代理角色等等...

Each UserApplication (UserWebsite) has its start and end date. And each Application has its own Role. A Bank website needs a Manager role. A Health Insurance Company website needs a Agent role and so on...

更新

我了解登录/用户(部分/全部)组合关系。在继续之前,请参阅回答关于组合与聚合。

I understand the login/user (part/whole) composition relationship. Before going on, see this answer about Composition versus Aggregation.


但是我不明白的是UserApplication和Application类的目的

But what I do not understand is the purpose of the UserApplication and Application classes

将应用程序视为您的网站。我为一个健康保险公司工作,我们有很多模块(每个模块(应用程序)都有自己的网站)。但是某些用户,而不是全部,可以使用每个模块。它解释了为什么我定义UserApplication。

Think of Application as your website. I work for a big Health Insurance Company where we have many modules (Each module (Application) has its own website). But some Users, not all, can use each module. It explains why i define UserApplication.


角色在此登录过程中的作用

role's role in this login process

无。它只是给一个UserApplication一个角色。我可以使用财务模块,其中定义了以下角色:经理,客户和其他,我可以担任经理的角色。但是我可以给您一个临时用户(startDate和endDate)作为客户使用财务模块。

None. It just gives an UserApplication a role. I can use the financial module, which defines the following roles: Manager, Customer and Other, where i can play the role of Manager. But i can assign you a Temporary User (startDate and endDate) as Customer to use the financial module.

Application financialModule = new Application();

financialModule.addRole(new Role("Manager"));
financialModule.addRole(new Role("Customer"));
financialModule.addRole(new Role("Other"));

User arthur = new User(new Login("#####", "#####"));
arthur.setFirstName("Arthur");
arthur.setLastName("Ronald");
arthur.setEnabled(true);

UserApplication financialModuleUser = new UserApplication(new Period(new Date(), null));
financialModuleUser.setUser(arthur);
financialModuleUser.addRole(financialModule.getRoleByDescription("Manager"));

financialModule.addUserApplication(financialModuleUser);

您的网站看起来像

Website myWebsite = new Website();
myWebsite.addRole(new Role("Member"));
myWebsite.addRole(new Role("WebMaster"));
myWebsite.addRole(new Role("Moderator"));

User you = new User(new Login("#####", "#####"));
you.setFirstName("FirstName");
you.setLastName("LastName");
you.setEnabled(true);

UserApplication myWebsiteUser = new UserApplication(new Period(new Date(), null));
myWebsiteUser.setUser(you);
myWebsiteUser.addRole(myWebsite.getRoleByDescription("WebMaster"));

myWebsite.addUserApplication(myWebsiteUser);

如您所见,WebMaster,版主和会员只是角色通过您的网站

As you can see, WebMaster, Moderator and Member are just roles defined by your website. Nothing else.

一个关于UML和ORM的好资源是Java持久化与Hibernate的书。

A good resource about UML and ORM is Java Persistence with Hibernate book.

这篇关于用于用户登录的UML类图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆