时间:2019-03-17 标签:c#WinformsMVC

发布于 2024-10-01 08:47:29 字数 339 浏览 3 评论 0原文

我以前从未使用过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烧了回忆取暖 2024-10-08 08:47:30

MVP模式更适合WinForms应用程序。这是 不错的文章你可以看看。

The MVP pattern is more adapted to WinForms applications. Here's a nice article you may take a look at.

躲猫猫 2024-10-08 08:47:30

公认的观点是,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.

我纯我任性 2024-10-08 08:47:30

MVC 模式可以与 WinForms 很好地配合使用,请参阅此问题

有很多相关图案可供选择;就 WinForms 而言(与 WPF 不同),没有明显的赢家。

部分原因是每个人都有不同的目标,您最关心的是:

  • UI 中 Form 之间的代码重用
  • 能够支持同一个 UI 系统
  • 简单的单元测试
  • 等等

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:

  • Code reuse between Forms in the UI
  • Being able to support form the one UI system
  • Easy unit testing
  • Etc
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文