这是MVC架构模式吗?
我最近创建了我的第一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您给出的定义的问题在于,它定义了您的应用程序的功能,但不一定定义了它的结构。 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.
with displaying information to the
user.
data.
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.
我不确定我是否理解这个问题。
如果您的意思是:“这符合 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?
您可以按照以下系列博客来将您的架构构建为 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