将用户界面与工作代码分开 [英] Separating the User Interface from your Working Code

查看:104
本文介绍了将用户界面与工作代码分开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



i我是编程初学者,我需要一些帮助

i在一个网站上阅读我应该从我的界面表格中分离编码,以及使用界面的最佳方式



我的问题是真的,如果是的话,你可以通过一些例子来帮助吗? br />


谢谢

解决方案

分离?好主意。 UI的分离比其他部分分离更重要,部分原因是由于社会/市场原因:有太多不同的UI系统和库,它们的变化速度比软件的其他部分要快,所以你需要需要能够快速采用它们。



首先,我建议你学习并分析以下架构模式的适用性(< a href =http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science)> http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science) [ ^ ]):



MVVM - 模型视图视图模型,

http://en.wikipedia.org/wiki / Model_View_ViewModel [ ^ ],


MVC - 模型 - 视图 - 控制器,

http:/ /en.wikipedia.org/wiki/Model-view-controller [ ^ ]),



MVA - 模型 - 视图 - 适配器,

http://en.wikipedia.org/wiki/Model-view-adapter [ ^ ],



MVP - 模型 - 视图 - 演示者,

http://en.wikipedia.org/wiki/模型 - 视图 - 演示者 [ ^ ]。

注意这些架构的动机。如果您了解它,您将能够正确地接近特定应用的设计。



-SA


看看我之前在这里做过的asnwer:解耦用户界面 [ ^ ]



与本文一起:详细的数据绑定教程 [ ^ ] - 应该可以帮到你开始了。



最好的问候

Espen Harlinn


你应该寻找在线文章这个。一般来说,你最好的选择是购买一本书并通过它来完成,而不是尝试遵循随机的建议。



你的代码确实应该与你的界面分开,如果在所有可能的。执行此操作的最佳方法是使用包含项目逻辑的dll,并让用户界面只处理控件上的事件,然后将值传递给dll。这样,如果您想要更改界面,只需编写一个调用相同dll的新界面即可。但是,如果你是初学者,你不应该担心这些事情。您甚至不应该担心表单,尽管您可以使用表单来驱动代码,但是您应该将C#或VB.NET作为一种语言进行学习,而不是担心设计的细节或UI开发的变幻莫测。

Hello

i am beginner in programming and i need some help
i read in a website that i should separate coding from my interface form, and the best way for that using Interface

my question is that true, and if yes, can you help by some example ?

and thank you

解决方案

Separating? Good idea. Separation of the UI is more important than other parts of separation, in part due to social/market reasons: the are too many different UI systems and libraries, and they change faster then other parts of the software, as well as requirements, so you need to be able to quickly adopt them.

To start with, I suggest you learn and analyze applicability of the following architectural patterns (http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science)[^]):

MVVM — Model View View Model,
http://en.wikipedia.org/wiki/Model_View_ViewModel[^],

MVC — Model-View-Controller,
http://en.wikipedia.org/wiki/Model-view-controller[^]),

MVA — Model-View-Adapter,
http://en.wikipedia.org/wiki/Model–view–adapter[^],

MVP — Model-View-Presenter,
http://en.wikipedia.org/wiki/Model-view-presenter[^].
Pay attention for the motivation of those architectures. If you understand it, you will be able to properly approach the design for a particular application.

—SA


Have a look at the asnwer I previously made here: decoupling user interface[^]

That, together with this article: A Detailed Data Binding Tutorial[^] - should help you get started.

Best regards
Espen Harlinn


You should look for online articles for stuff like this. In general, your best bet is to buy a book and work through it, not try to follow random advice.

Your code should indeed be seperate from your interface if at all possible. The best way to do this, is to have a dll that contains the logic of your project, and have your user interface just handle events on controls and then pass values through to the dll. That way, if you ever want to change your interface, you just write a new interface that calls the same dll. However, if you're a beginner, you shouldn't be worried about such things. You shouldn't even worry about forms, although you can use forms to drive your code if you like, you should work on learning C# or VB.NET as a language, not worried about the niceties of design or the vagaries of UI development.


这篇关于将用户界面与工作代码分开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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