英文:
In MVC what is a GUI model in opposition to Application model?
问题
在开发Java Swing MVC应用程序时,GUI模型与应用程序模型相对立。为什么GUI模型与MVC相关?
我在这里的示例中阅读了相关信息(http://web.archive.org/web/20170723150710/http://java-articles.info/articles/?p=555),但该示例未使用GUI模型。更多信息可以在这里找到(https://softwareengineering.stackexchange.com/a/145004/93338),在这里(https://stackoverflow.com/a/8435025/2241463)以及在这里(https://wiki.c2.com/?ModelPipeViewController)。此外,在A Swing Architecture Overview 的 "GUI-state vs. application-data models" 部分也有相关内容。
为了引用示例的作者:
>最后,这是我在Java Swing中实现模型/视图/控制器模式(MVC)的方式。
>
>视图可以从模型中读取值。视图不能更改模型中的值。
>
>控制器将(可能)更改模型中的值。
>
>控制器(可能)会导致视图重新绘制。
>
>通常情况下,我没有一个主控制器。我会让每个控制器都完成自己的任务。
>
>通常情况下,我会有一个主模型。有时,你可能需要多个GUI模型。但这不是那种情况之一。当您的GUI是一个更大的Java应用程序的一部分时,GUI模型通常与应用程序模型分开。
英文:
When developing Java Swing MVC apps, what is a GUI model in opposition to an Application Model? And why is it relevant to MVC?
I read about it the example here (the example does not use a GUI model though). Found more information about it here, here and here. Also in A Swing Architecture Overview in the section GUI-state vs. application-data models.
To cite the author of the example:
>Finally, this is how I implement the model / view / controller pattern (MVC) in Java Swing.
>
>The view may read values from the model. The view may not change values in the model.
>
>The controller will (probably) change values in the model.
>
>The controller will (probably) cause the view to repaint.
>
>I don’t have one master controller, usually. I let each controller do its thing.
>
>I do usually have one master model. Sometimes, you need more than one GUI model. This isn’t one of those times. The GUI model is usually separate from the application model, when your GUI is part of a much larger Java application.
答案1
得分: 0
关键在于缩写'MVC',其意为模型-视图-控制(Model View Control)。遵循MVC原则的应用将数据模型(业务数据)与控制(管理业务数据的逻辑)以及视图(管理图形用户界面的代码,简称GUI)分开。
因此,GUI模型是用户界面的模型,而应用程序模型不是特定于MCV模型的某部分。从理论上讲,它可以覆盖整个应用程序。值得一提的是,我在这里将“模型”一词与描述性表示同义使用,例如类模型或控制流程图。但在其他情境中,“模型”可能具有更多含义。例如,业务类的组合可以称为业务模型,而应用程序中的类组合可以称为应用程序模型。
英文:
The key lies in the abbreviation 'MVC' which means Model View Control. An application that complies with the MVC principle differentiates the data model (business data) from the control (the logic managing the business data) from the view (the code managing the graphical user interface - or GUI for short).
Thus a GUI model is a model of the UI, while an application model is a model not specific to a portion of the MCV model. It could theoretically cover the entire application. It is maybe worth mentioning, that I use the word model synonymously with descriptive representation, as in a class model, or a control flow chart. But model can mean more in other contexts. For example the combined set of business classes can also be called the business model, while the combined classes in an application could be called the application model.
专注分享java语言的经验与见解,让所有开发者获益!
评论