这是MVC架构模式吗?

发布于 2024-09-30 00:55:45 字数 195 浏览 3 评论 0原文

我最近创建了我的第一个 C# 桌面应用程序。它模拟数据交换。该应用程序存储和读取两个文本文件中的数据。使用此应用程序时,用户必须首先输入用户名和密码登录。然后,应用程序读取包含所有用户名和密码的第一个文本文件。如果在第一个文本文件中找到该用户名和密码,则登录成功。登录后,用户可以在文本框中输入数据。该数据保存在另一个文本文件中。我的问题是我可以将这个软件架构定义为MVC吗?

I've recently created my first c# desktop application. It simulates data exchange. The application stores and reads data from two text files. When using this application, user must first login by entering username and password. The application then reads the first text file which contains all usernames and passwords. Login is successful if that username and password is found in the first text file. After the login, user can enter data in the text box. That data is saved in the other text file. My question is can I define this software architecture as MVC?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

手心的温暖 2024-10-07 00:55:45

您给出的定义的问题在于,它定义了您的应用程序的功能,但不一定定义了它的结构。 MVC 背后的概念是开发隔离不同利益的代码。

  • 你的表现层关心
    与显示信息
    用户。
  • 您的模型与处理有关
    数据。
  • 您的控制器关心的是
    处理另外两个之间的管道。

这样做的原因主要是为了帮助测试和维护代码。有关 MVC 的一些信息,您可能需要查看 MVC 的维基百科页面

The problem with the definition that you've given is that it defines WHAT your application does but not necessarily how it's structured. The concept behind MVC is developing code that isolates different interests.

  • Your presentation layer is concerned
    with displaying information to the
    user.
  • Your model is concerned with handling
    data.
  • Your controller is concerned with
    handling the plumbing between the other two.

The reasons for this are primarily to aid in testing and maintenance of the code. For some information on what MVC is, you might want to look at the Wikipedia page on MVC.

撩起发的微风 2024-10-07 00:55:45

我不确定我是否理解这个问题。

如果您的意思是:“这符合 MVC 模式吗?”,那么答案是我们无法告诉您,因为您还没有定义代码的布局方式。

如果您的意思是:“我可以为此软件应用程序实现 MVC 模式吗?”那么答案是肯定的。如果您还没有的话,您可以这样做。但是,如果您已经可以使用它,为什么要更改它,除非您打算将其作为要长期维护的生产系统发布?

I'm not sure I understand the question.

If you meant: "Does this conform to the MVC pattern?" then the answer is we can't tell you because you haven't defined how the code is laid out.

If you meant: "Can I implement the MVC pattern for this software application?" then the answer is yes. You can if you want to if you haven't already. But if you have it working already, why change it unless you're going to be releasing it as a production system that you're going to be maintaining for a long period of time?

风和你 2024-10-07 00:55:45

您可以按照以下系列博客来将您的架构构建为 MVP:http://codebetter.com/blogs/jeremy.miller/archive/2007/07/25/the-build-your-own-cab-series -table-of-contents.aspx 如果您正在构建 winforms 桌面应用程序

You can structure your architecture as MVP by following this series of blogs @ http://codebetter.com/blogs/jeremy.miller/archive/2007/07/25/the-build-your-own-cab-series-table-of-contents.aspx if you're building a winforms desktop app

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文