如何实现独立于UI的应用程序? [英] How does one implement UI independent applications?

查看:105
本文介绍了如何实现独立于UI的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使我的C#源代码UI的大部分内容独立的基本技术是什么?

What are the fundamental techniques to make most part of my C# source code UI independent?

例如,我想为Winforms桌面应用程序编写源代码,我将能够通过很小的改动将其插入asp.net Web应用程序或WPF应用程序. IE.无论UI技术如何,我都将能够使用相同的源代码,以使其面向未来.

For example, I would like to write my source code for Winforms desktop application which I shall be able to plug into asp.net web application or a WPF application with very minor changes. I.e. I shall be able to use the same source code irrespective of UI technology to make it future-proof.

我知道 CSLA框架可以做到这一点.

I know CSLA framework can do that.

但是,如果我不使用CSLA(学习一个新框架需要花费一些时间,而目前我没有太多时间花在它上面),那么应该注意哪些方面来实现这种目标?我的C#代码有能力吗?

But if I don't use CSLA (it takes some time to learn a new framework and at present I don't have that much time to spend on it), what points should be taken care of to achieve this kind of ability in my C# code?

能给我一个例子吗?我已经在我的应用程序中使用了业务对象和分层技术.但是即使如此,我仍然看到它需要大量编码才能将我的代码插入新的UI技术.

Can you give me an example? I already use Business Objects and layering technique in my applications. But even so I have seen that it needs a lot of coding to plug my code to new UI technologies.

请不要给我任何肤浅的答案.

Please do not provide me with any superficial answer.

推荐答案

进行UI独立编码的最佳方法是将逻辑与表示分离.看看 MVC模式.

The best way to do UI independent coding is to seperate the logic from the presentation. Take a look at the MVC pattern.

这更多是与设计有关的学科问题,而不是框架问题.框架不能强迫您进行适当的设计.如果您正确设计应用程序,它可以使您更轻松地进行操作,但是始终可以通过各种方式来执行它.

This is more of an discipline issue with your design rather than a framework issue. A framework can't not force you to design properly. It can make things easier for you if you design the app properly, however there are always ways around the enforcement of it.

这篇关于如何实现独立于UI的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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