C#MVP是什么模型? [英] C# MVP What is the model?

查看:120
本文介绍了C#MVP是什么模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在上一个项目中第一次开始使用MVP,现在我对此感到非常困惑.

I started using MVP for the first time on my last project and I'm absolutely confused with it now.

我从MVP中学到的是: MVP中的模型确实存在,只是为了提供视图所需的内容,以及仅提供视图所需的内容.

What I was taught regarding MVP is that: The Model in MVP really exists just to provide exactly what the view needs and only what it needs.

因此,我认为要获得的模型不太可能代表具有实际逻辑的类/对象.

So the models that my view would be getting, are unlikely to be representing classes/objects with actual logic on them.

实际上,它们更有可能只是数据传输对象,并且所有设置都完美无缺,因此视图除了显示合适的数据外无需执行任何操作.

They are in fact, a lot more likely to be just data transfer objects with everything set-up perfectly so that the view has to do nothing but display the data however it sees fit.

但是,从我在线收集的数据来看,模型层是我大多数业务逻辑应驻留的位置.

BUT from what I gathered online, the model layer is where most of my business logic should reside in.

为什么我在网上找到的关于模型的东西与我所教的东西如此不同?

Why is what I'm finding online about models so different from what I've been taught?

我很确定我在这里混淆了概念,我真的需要帮助来弄清这些混乱.

I'm pretty sure I'm confusing concepts here and I really need help in untangling this mess.

推荐答案

我认为您处在正确的轨道上,Presenter层应处理大多数业务逻辑,而Model层应表示您的数据或域模型.无论如何,这就是我正在研究的文本所建议的内容,它似乎为Web Forms中的SOLID提供了良好的基础.

I think you're on the right track, the Presenter layer should handle most business logic and the Model layer should represent your data or domain model. This is what the text I am working through suggests anyway, and it seems to provide a nice foundation for SOLID in Web Forms.

这篇关于C#MVP是什么模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆