I am a bit confused in what the application controller should do? Because I see the functionality will also exists in your MVP pattern to make the decisions which form should be shown when a button is clicked? Are there any good examples for Windows Forms that uses the application controller pattern?
我对应用程序控制器应该做什么有点困惑?因为我看到MVP模式中也存在功能,以便在单击按钮时显示哪些表单?对于使用应用程序控制器模式的Windows窗体,是否有任何好的示例?
There is a difference in the MVC(ontroler) and the Application Controller. I know the MVC(ontroller), I am not sure what is the responsibilities for an Application Controller, and how does it fit into a WinForms application. Martin Fowler also calls this the Application Controller pattern, surely it is not the same thing as the MVC(ontroller)?
MVC(ontroler)和Application Controller存在差异。我知道MVC(ontroller),我不确定应用程序控制器的职责是什么,以及它如何适用于WinForms应用程序。 Martin Fowler还将其称为应用程序控制器模式,当然它与MVC(ontroller)不同?
3 个解决方案
#1
12
I recently wrote an article on creating and using an ApplicationController in a C# Winforms project, to decouple the workflow and presenters from the forms directly. It may help:
我最近写了一篇关于在C#Winforms项目中创建和使用ApplicationController的文章,以直接将工作流和演示者与表单分离。它可能有所帮助:
Decoupling Workflow And Forms With An Application Controller
使用应用程序控制器解耦工作流和表单
edit:
Archive.org has got a more readable copy of the article at this time.
编辑:Archive.org目前有一篇更易读的文章副本。
#2
12
An Application Controller is a bit of a different beast than the controller used in MVC.
应用程序控制器与MVC中使用的控制器有点不同。
Martin Fowler's page on the Application Controller.
Martin Fowler关于应用程序控制器的页面。
In the case of an MVP WinForms app, which seems to be what the question topic is about I think. You can put all the logic for "what form do I show now" into the Presenter, but as your application grows you're going to be duplicating a lot of code between Presenters.
在MVP WinForms应用程序的情况下,这似乎是我认为的问题主题。您可以将“我现在显示的格式”的所有逻辑放入Presenter,但随着应用程序的增长,您将在演示者之间复制大量代码。
Say you have 2 views that both have a button for "Edit this Widget", both of them would have to have logic to get a WidgetEditorPresenter and show the associated view. If you have an ApplicationController, you move that logic into the ApplicationController, and now you simply have a dependency in all your presenters on the ApplicationController and you can call appController.EditWidget() and it will pop up the correct view.
假设您有2个视图都有“编辑此窗口小部件”的按钮,它们都必须具有获取WidgetEditorPresenter并显示关联视图的逻辑。如果你有一个ApplicationController,你将该逻辑移动到ApplicationController中,现在你只需要在ApplicationController上的所有演示者中有一个依赖项,你就可以调用appController.EditWidget(),它会弹出正确的视图。
The application controller is an uber-controller that controls application flow throughout your system as you move from screen to screen.
应用程序控制器是一个超级控制器,可以在您从一个屏幕移动到另一个屏幕时控制整个系统的应用程序流。
#3
0
Personally I have no experience with MVP or winforms, but I have worked with MVC. I hope this is what you're asking, otherwise ignore my answer completely.
我个人没有MVP或winforms的经验,但我曾与MVC合作过。我希望这就是你所要求的,否则完全无视我的回答。
The C in MVC is responsible for more than just choosing the next view to be presented to the client. It holds most, preferably all, business-logic of the application, including performance of system tasks (such as logging and enforcement of permissions upon the flow of data from the model and to it).
MVC中的C不仅仅是选择要呈现给客户端的下一个视图。它包含应用程序的大多数(最好是所有)业务逻辑,包括系统任务的执行(例如,从模型到数据流的数据流的日志记录和执行权限)。
Its primary task is, naturally, to serve the presentation layer above it and separate it from the model layer below while mediating between them. I guess you can think of it as the brain of the application.
当然,它的主要任务是服务于它上面的表示层,并将它与下面的模型层分开,同时在它们之间进行调解。我想你可以把它当作应用程序的大脑。
Hope this helps,
希望这可以帮助,
Yuval =8-)
#1
12
I recently wrote an article on creating and using an ApplicationController in a C# Winforms project, to decouple the workflow and presenters from the forms directly. It may help:
我最近写了一篇关于在C#Winforms项目中创建和使用ApplicationController的文章,以直接将工作流和演示者与表单分离。它可能有所帮助:
Decoupling Workflow And Forms With An Application Controller
使用应用程序控制器解耦工作流和表单
edit:
Archive.org has got a more readable copy of the article at this time.
编辑:Archive.org目前有一篇更易读的文章副本。
#2
12
An Application Controller is a bit of a different beast than the controller used in MVC.
应用程序控制器与MVC中使用的控制器有点不同。
Martin Fowler's page on the Application Controller.
Martin Fowler关于应用程序控制器的页面。
In the case of an MVP WinForms app, which seems to be what the question topic is about I think. You can put all the logic for "what form do I show now" into the Presenter, but as your application grows you're going to be duplicating a lot of code between Presenters.
在MVP WinForms应用程序的情况下,这似乎是我认为的问题主题。您可以将“我现在显示的格式”的所有逻辑放入Presenter,但随着应用程序的增长,您将在演示者之间复制大量代码。
Say you have 2 views that both have a button for "Edit this Widget", both of them would have to have logic to get a WidgetEditorPresenter and show the associated view. If you have an ApplicationController, you move that logic into the ApplicationController, and now you simply have a dependency in all your presenters on the ApplicationController and you can call appController.EditWidget() and it will pop up the correct view.
假设您有2个视图都有“编辑此窗口小部件”的按钮,它们都必须具有获取WidgetEditorPresenter并显示关联视图的逻辑。如果你有一个ApplicationController,你将该逻辑移动到ApplicationController中,现在你只需要在ApplicationController上的所有演示者中有一个依赖项,你就可以调用appController.EditWidget(),它会弹出正确的视图。
The application controller is an uber-controller that controls application flow throughout your system as you move from screen to screen.
应用程序控制器是一个超级控制器,可以在您从一个屏幕移动到另一个屏幕时控制整个系统的应用程序流。
#3
0
Personally I have no experience with MVP or winforms, but I have worked with MVC. I hope this is what you're asking, otherwise ignore my answer completely.
我个人没有MVP或winforms的经验,但我曾与MVC合作过。我希望这就是你所要求的,否则完全无视我的回答。
The C in MVC is responsible for more than just choosing the next view to be presented to the client. It holds most, preferably all, business-logic of the application, including performance of system tasks (such as logging and enforcement of permissions upon the flow of data from the model and to it).
MVC中的C不仅仅是选择要呈现给客户端的下一个视图。它包含应用程序的大多数(最好是所有)业务逻辑,包括系统任务的执行(例如,从模型到数据流的数据流的日志记录和执行权限)。
Its primary task is, naturally, to serve the presentation layer above it and separate it from the model layer below while mediating between them. I guess you can think of it as the brain of the application.
当然,它的主要任务是服务于它上面的表示层,并将它与下面的模型层分开,同时在它们之间进行调解。我想你可以把它当作应用程序的大脑。
Hope this helps,
希望这可以帮助,
Yuval =8-)