MVP如何产生看法? 提交者是否总是创建这些职位(除了在分观点方面的观点之外)? 或者,它是一个单独的第三方组成部分或应用,还是产生这些成分的东西?
我还要指出,我很可能在Dojo Toolkit/ExtJS(Java编)上这样做。
因此,我有这些法典:
var v = new MyApp.view.User();
var p = new MyApp.presenter.User();
这两条路线究竟在何处? 陈述人是否即时表示意见,还是反面意见? 什么是初审?
MVP如何产生看法? 提交者是否总是创建这些职位(除了在分观点方面的观点之外)? 或者,它是一个单独的第三方组成部分或应用,还是产生这些成分的东西?
我还要指出,我很可能在Dojo Toolkit/ExtJS(Java编)上这样做。
因此,我有这些法典:
var v = new MyApp.view.User();
var p = new MyApp.presenter.User();
这两条路线究竟在何处? 陈述人是否即时表示意见,还是反面意见? 什么是初审?
它取决于......
The main goal of MVP is to separate complex decision logic from UI code in such a way that both become easier to understand and to maintain. Often another goal is to make the decision logic in the presenter testable.
The MVP pattern was described by Fowler in 2004 and he retired it in 2006 by splitting the pattern into Supervising Conroller (SC) and Passive View (PV). In SC, the View is bound to the Model but not in PV; in PV, the View is only changed by the Presenter directly.
在SC和PV中,提交者必须更新意见和,对用户对意见所作的改动作出反应,例如进入案文或将一个纽扣。 当您请见面人时,就会出现你描述的问题,因为观点需要提及发言者,反之亦然。 如果你这样做,那么你就能够作出决定,由谁来决定。 备选办法如下:
All options allow you to reach "MVP goals" of separation of concerns and increased testability of decision logic. I don t think any of these methods is theoretically right or wrong –you just have to pick the one that is most appropriate to the technology you use. And it s best to be consistent in your choice throughout the application.
These are your options:
var cvp = new ContactViewPresenter(new ContactView());
ContactViewPresenter
constructor sets this.view = viewParam
, and sets this.view.presenter = this
.
It keeps the code in the Presenter, it can swap out views if necessary, and it could pass in a mock of the view for testing.
var cv = new ContactView(new ContactViewPresenter());
ContactView
constructor sets this.presenter = cvpParam
, and this.presenter.view = this
.
Some logic in View, but not a lot. Can swap out presenter if necessary.
ContactView cv = new ContactView();
ContactViewPresenter cvp = new ContactViewPresenter();
cv.presenter = cvp;
cvp.view = cv;
cv.init();
cvp.init();
这是更多的法典。
ContactViewPresenter cvp = new ContactViewPresenter();
Constructor创设了this.view = 新的联系意见(
和this.view.presenter = 这一
。
ContactView cv = new ContactView();
Constructor set this.presenter = new CrossViewPresenter(
and this.presenter.view = this
最后两条似乎太过了。
一种看法是,该守则在提交者中停留,似乎便于测试。
两点是,你不必过多地照顾到发言者,并对你们感到担忧。 更多意见。
I< t>,theer view, that should be Immediateiate, that should do be made by an entities (>, in the data-Orientness, I mean a general entities) than the MVP. 例如,控制(IoC)框架(如果你听说过IoC, «a href>http://martinfowler/com/in>. > > > < > > > >。 Martin Fowler s articles/a, 或者, 或者 某些申请是:
如果你使用网上表格,那么网上网站“Load”或“Init”就应当成为你创建网站的地方,然后通过一个接口,提及网上论坛所执行的观点。
因此:
Presenter _presenter;
OnLoad(object sender, EventArgs e)
{
_presenter = new Presenter(this);
_presenter.Initialise();
}
因此,目前建筑商的定义是:
public class Presenter
{
public Presenter(IView viewReference)
{
_viewReference = viewReference;
}
}
我的术语可能有些错误,但我认为你需要确定你们互动的构成基础;开始互动的是什么?
In the Webforms example I gave, the Webform is created by the Http pipeline, the OnInit or OnLoad event is the first point in the pipeline ( depending on what context you need ) that you can hook in to the process. Thus, you create a Presenter and give it your concrete instance of a Webform as a View Interface.
I don t know the Javascript frameworks you are discussing but I presume there is an initialisation / invocation step - in ASP.NET MVC this is when an ActionInvoker gets involved, it s the Main in a Console App.
After reading this question I started to wonder: is it possible to have a shuffling algorithm which does not modify or copy the original list? To make it clear: Imagine you are given a list of ...
I wanted to know why the default value for a variable for a method of a class, cannot be a non-static method or member of the same class. Is there a reason for that ? Could not the compiler provide ...
I ve never used python before. I ve used php for about 5 years now. I plan to learn python, but I m not sure what for yet. If I can think of a project that might be better to do in python, I ll use ...
Theoretically, can one define a protocol where one machine does some remote calls on another machine (or more than one), and where in any part of the process, if any of the machines (or operations) ...
Im building a site where a user can add people to their "list". This list belongs to the user, but im wondering whats the best way to store/retrieve/loop through this list in a function, to show the ...
I ve found that lots of people use the words closure and block interchangeably. Most of these people can t explain what they re talking about. Some Java programmers (even ones from really expensive ...
Motivation: I d like to be able to use toy functional programming in languages without first-order functions, by using natural numbers instead of functions. A universal function is a function f : N ->...
What is the fastest algorithm that exists up with to solve a particular NP-Complete problem? For example, a naive implementation of travelling salesman is O(n!), but with dynamic programming it can be ...