简体   繁体   English

我的 java 应用程序的 MVC UML 图中的不连贯性

[英]Incoherence in my MVC UML diagram for java app

I am making an app in java. I decided to go with an MVC architecture.我正在 java 中制作应用程序。我决定使用 MVC 架构的 go。

My app has a login page.我的应用程序有一个登录页面。 The database is accessed with JDBC. The app has a graphical user interface (gui) that I will do with.netbeans gui builder and swing.使用 JDBC 访问数据库。该应用程序具有图形用户界面 (gui),我将使用 .netbeans gui builder 和 swing。

The user uses the GUI, the GUI sends the form to the controller, the controller contacts the database, the database responds, the controller relay to the gui etc.用户使用GUI,GUI将表单发送到controller,controller联系数据库,数据库响应,controller中继给gui等。

So far my uml diagram looks like this:到目前为止,我的 uml 图如下所示:

当前 MVC 图

My friend told me, that there is inconsistency in my diagram because the database is external to the architecture.我的朋友告诉我,我的图中存在不一致,因为数据库在体系结构之外。 Plus my controller is too vague.加上我的 controller 太模糊了。 And it is better to put the button_handler in the view.最好将 button_handler 放在视图中。 If I do that, what shall I put in my model?如果我这样做,我应该在我的 model 中输入什么? And how to be more precise about the controller to make it easier to implement in JAVA?以及如何将controller更精确,使其更容易在JAVA中实现?

The diagram is indeed inconsistent, confusing and incorret:该图确实不一致,令人困惑且不正确:

  • is inconsistent because it uses packages to group several classes, but tries to show a kind of relation that UML does not support between packages.是不一致的,因为它使用包来对几个类进行分组,但试图显示一种 UML 不支持的包之间的关系。

  • is confusing, because it shows in one diagram elements that correspond to very different views: on one side classes, which are typical of a class diagram, and on the other side processing nodes (DB) that you'd normally expect in a deployment diagram.令人困惑,因为它在一个图表中显示了对应于非常不同的视图的元素:一方面是类,这是典型的 class 图表,另一方面是您通常在部署图中期望的处理节点 (DB) .

  • it is wrong, because your <<login>> package is made out of information that are not relevant for UML.这是错误的,因为您的<<login>> package 是由与 UML 无关的信息组成的。

But I think your friend is right for the wrong reasons.但我认为你的朋友是对的,但理由是错误的。 You could very well show a DB in your model (provided you did it correctly), even if it is an independent interchangeable component and even if you don't develop it yourself.你可以很好地在你的 model 中显示一个 DB(前提是你做得正确),即使它是一个独立的可互换组件,即使你不自己开发它。 Your system, your boundaries!您的系统,您的边界!

Now, to get your diagram right, you need to decide what you want to show:现在,为了让图表正确,您需要决定要显示的内容:

  • If it is about classes, use a simple class diagram.如果是关于类的,使用简单的 class 图。 If you show a package, be careful to keep the associations between the classes.如果显示 package,请注意保持类之间的关联。 You could even have a class that represents a DB connection as proxy for the DB.您甚至可以使用 class 表示数据库连接作为数据库的代理。
  • If you want to show the high-level components you could go for a component diagram.如果您想显示高级组件,您可以 go 获取组件图。
  • But if you want to show an overview on components with a zoom on what's in, you could give the composite structure a trial.但是,如果您想显示组件的概览并放大其中的内容,您可以试用复合结构

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM