简体   繁体   English

如果“Presenter”在“视图”上设置属性是否违反了MVP模式?

[英]If “Presenter” is setting a Property on the “View” is it a violation of MVP Pattern?

I am new to MVP and trying to get the picture. 我是MVP的新手并试图了解情况。

And I am stucked at one point: 而且我被困在一点:

In order to be able to unit-test more on my View, I would like to also shift some property settings to PRESENTER. 为了能够在我的View上进行单元测试,我还希望将一些属性设置转移到PRESENTER。 So that I can see if some View properties are set and also set properly. 这样我就可以看到是否设置了一些View属性并设置正确。

But at this point my 6th sense is whispering me quite noisy that I started to doubt if I am breaking MVP pattern by doing this. 但是在这一点上,我的第六感很让我耳语,我开始怀疑我是否通过这样做打破了MVP模式。 Because it sounds like "setting" more than "presenting" to me :( 因为它听起来像“设置”而不是“呈现”给我:(

So, if "Presenter" is setting a Property on the "View" is it a violation of MVP Pattern? 那么,如果“Presenter”在“视图”上设置属性是否违反了MVP模式?

Thanks 谢谢

In MVP the Presenter is supposed to set properties on the View. 在MVP中,Presenter 应该在View上设置属性。 You may be thinking of MVC where the Controller is simply responsible for handing the View a reference to the Model. 您可能正在考虑MVC,其中Controller只负责将View引用交给Model。 In MVP the Presenter is typically pretty tightly tied to the View and responsible for directly setting properites. 在MVP中,Presenter通常与View紧密相关,并负责直接设置属性。

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

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