时间:2019-03-17 标签:c#WinformsMVC
我以前从未使用过 MVC,希望得到一些建议。
我其实已经写了相当多的代码了,但是看了一下,类之间的耦合度似乎相当高,而且有很多代码是写在winform的实际主窗体上的。我是一名大学生,最近开始为期 12 个月的实习,所以没有太多现实世界的经验。
我的系统实际上是一个 WinForm GUI,除其他外,它还具有一个在加载时通过事件填充的树视图。然后,当用户单击一个节点时,它会从 dllplugin 获取 datagridview(它通过 perl 脚本从 Oracle DB 获取数据。
我的问题是 MVC 是否适用于这种情况,以及有人有什么好的建议/关于我现在如何实现资源的后期设计,
谢谢。
I have never used MVC before and would like some advice.
I have actually already written quite a bit of code, but looking at it, it seems to be quite highly coupled between classes and there is a lot of code written on the actual main form of the winform. I am a University student, recently started on a 12 month placement, so do not have much real world experience.
My system is effectively a WinForm GUI that has, amongst other things, a treeview that is popualted at load via an event. And then when the user clicks on a node, it gets a datagridview from a dllplugin (which obtains the data from an Oracle DB via a perl script.
My question, is would MVC apply in this circumstance, and would anybody have any good advice/resources on how I can now, post-design to implement it?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
MVP模式更适合WinForms应用程序。这是 不错的文章你可以看看。
The MVP pattern is more adapted to WinForms applications. Here's a nice article you may take a look at.
公认的观点是,MVC 对 Web 有好处,但在桌面环境中操作时有一些限制(我在这两种情况下应用这种模式都没有足够的经验来做出有价值的判断)。
Microsoft(例如)正在推动表单使用的模式是 MVVM(模型视图视图模型),它在分离和可测试性方面提供了一组类似的好处。即使允许我希望我知道更多,我也能明白是什么和原因,特别是如果您正在研究 WPF(和 Silverlight),但在任何您试图确保分离的环境中。
Received wisdom is that MVC is good for the web but has some constraints when operating in a desktop environment (I'm not sufficiently experienced in applying this sort of pattern in either context to make a worthwhile judgement).
The pattern that Microsoft (for one) are pushing for forms use is MVVM - which is Model View View Model - and it provides a similar set of benefits in terms of separation and testability. Even allowing that I could wish I knew more I can see what and why, especially if you're looking at WPF (and Silverlight) but in any context where you're trying to ensure separation.
MVC 模式可以与 WinForms 很好地配合使用,请参阅此问题。
有很多相关图案可供选择;就 WinForms 而言(与 WPF 不同),没有明显的赢家。
部分原因是每个人都有不同的目标,您最关心的是:
The MVC pattern can work well with WinForms, see this question.
There are lot of related pattern to choose from; in the case of WinForms (unlike WPF) there is no clear winner.
Partly this is due to everyone having different aims, do you care most about: