使用服务而不是组件的优点和缺点是什么? [英] What is the advantages and disadvantages of using services over components?

查看:27
本文介绍了使用服务而不是组件的优点和缺点是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从过去几个月开始,我在最新的 .net 框架中从事项目.

From past few months I am working on projects in latest dot net frameworks.

我觉得在最新的 .net 版本中,服务"比组件更受鼓励.对吗?

I feel that in latest dot net versions "services" are encouraged over components. Is that correct?

我见过银光(我是银光的初学者)所有的DB层操作都是作为服务暴露的.不知道现在组件程序也有吗?

I have seen in silver light (I am a beginner in silver light) all the DB layer operations are exposed as services. I don't know right now component programs also are available?

有什么优势?如果所有层都公开为服务而不是 DLLS,那么性能如何?

What is the advantages? What about the performance if all the layers are exposed as services instead of DLLS?

请通过对这个主题的一些了解,我应该从哪里开始正确理解这个概念?

Please through some light on this subject that where should I begin to understand this concept correctly?

谢谢

SC

推荐答案

这实际上与面向服务的架构有关 - 一段时间很常见并且非常流行.

It's really all to do with a Service Oriented Architecture - something that's been common for a while and is very popular.

这个想法是不同的操作彼此分离,这样它们就可以被重用和修改,而无需重新编译使用它的应用程序.可以部署代表特定处理或信息源的单一访问点的服务,而不是 DLL 中的一段代码被修改和复制到任何地方.

The idea is that distinct operations are decoupled from each other so they can be reused and modified without recompiling the apps that use it. Rather than a piece of code in a DLL being modified and copied everywhere, a service can be deployed that represents a single point of access for a particular piece of processing or source of information.

假设您有一个信用卡验证组件.您可以编写此代码并将其编译为 DLL,然后开始将其包含在您的所有应用程序中.除非您注意到错误或 CC 验证规则发生变化,否则这没有任何问题.或者您可能想升级它以根据黑名单进行检查.如果不重新编译使用它的应用程序,您将无法执行任何这些操作.

Say you had a credit card validation component. You may write this code and compile it into a DLL and start including that in all your applications. Nothing wrong with that unless you notice a bug or the rules for CC validation change. Or maybe you want to upgrade it to check it against a blacklist. You can't do any of those things without recompiling the apps that use it.

如果您的信用卡验证作为服务公开,您可以进行更改并部署到一个位置.如果签名相同(相同的参数和响应),应用程序甚至不必知道它已更改.

If your credit card validation is exposed as a service however, you can make the changes and deploy to one location. Provided the signature is the same (same parameters and response), the applications don't even have to know it's changed.

使用服务而不是组件的另一个优点是服务可以托管在任何地方.它们可以在本地服务器上,也可以在世界的另一端.

Another advantage of using services over components is that the services can be hosted anywhere. They can be on the local server or on the other side of the world.

话虽如此,就像所有事情一样,您应该根据具体情况决定架构.虽然信用卡验证是服务何时有用的一个很好的例子,但提供呈现 HTML 控件的服务并没有多大意义.

Having said this, like everything you should decide the architecture on a case-by-case basis. While the credit-card validation was a good example of when a service is useful, providing a service to render HTML controls doesn't make much sense.

这篇关于使用服务而不是组件的优点和缺点是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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