分布式服务比分布式对象更好在哪里?

发布于 2024-08-27 21:30:27 字数 161 浏览 7 评论 0原文

我对技术不感兴趣,例如 CORBA 与 Web 服务,我对原理感兴趣。当我们进行 OOP 时,为什么我们要在更高层次上有如此程序化的东西?这与OOP和关系数据库不是一样吗?通常服务是通过代码生成来支持的,除了样板之外,我认为这是因为我们新的 SOM - 服务对象映射器。再说一次,服务而不是对象的原因是什么?

I am not interested in the technology e.g. CORBA vs Web Services, I am interested in principles. When we are doing OOP, why should we have something so procedural at higher level? Is not it the same as with OOP and relational databases? Often services are supported through code generation, apart from boilerplate, I think it is because we new SOM - service object mapper. So again, what are the reasons for wervices rather than objects?

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

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

发布评论

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

评论(5

近箐 2024-09-03 21:30:27

分布式服务与分布式对象之间的主要区别在于,服务及其操作根据定义是粗粒度的,而对象默认是细粒度的。

在进行远程调用时,网络延迟是一个事实,并且界面越粗糙越好。面向服务的模式和实践侧重于构建此类接口。

所以,总而言之,问题不在于技术或协议(二进制 vs XML),而在于使用场景。您可以在 CORBA 中创建“服务”并在 WCF 中进行老式分布式对象编程,但前者似乎更偏向于对象,而后者则更偏向于服务......

The main difference between distributing services vs distributing objects is that services and their operations are by definition coarse-grained while objects are by default fine-grained.

When doing remote calls, network latency is a fact and the more coarse is your interface, the better. Service-oriented patterns and practices focus on building such interfaces.

So, to sum up, the problem is not in the technology or protocol (binary vs XML) but rather in usage scenarios. You can create 'services' in CORBA and do old-school distributed objects programming in WCF, but the former seems to be more biased towards objects while the latter -- towards services...

逆流 2024-09-03 21:30:27

分布式对象和远程过程调用有点像进程之间的共享状态,而服务是自包含的。

它可以与共享状态语言中的普通 OOP 和使用 Actor 模型且无共享状态的语言之间的关系进行比较(例如在 Erlang 中,您有很多轻量级进程不共享任何内容,而是通过消息进行通信)仅有的)。 Actor 模型方法要简单得多,并且可以为您带来并发性等方面的好处。

Distributed objects and remote procedure calls are kind of like shared state between processes, while Services are self contained.

It can be compared to the relationship between normal OOP in a shared state language, and a language using the Actor model and no shared state (like in Erlang, where you have a lot of light-weight processes not sharing anything, but communicating through messages only). The Actor model approach is much less complex, and can give you benefits in relation to concurrency etc.

泪意 2024-09-03 21:30:27

恕我直言,在高水平上几乎没有什么区别。但在实现层面,分布式对象、CORBA、Java RMI 等还有很多不足之处。我尝试在实际生产系统中使用 CORBA 和后来的 RMI,但保持版本同步是一场噩梦。

这些天,我发送消息并得到回复。

IMHO, there is little difference at a high level. But at an implementation level, distributed objects, CORBA, Java RMI, etc. leave a lot to be desired. I tried to work with CORBA and later RMI in real production systems, and keeping versions in sync was a nightmare.

These days, I send messages and get responses.

九局 2024-09-03 21:30:27

分布式对象意味着什么?必须同步的同一个对象的两个副本?两阶段提交对对象的每个更改?复杂的。

在网络中将对象从一个位置移动到另一个位置?在这种情况下,您必须确保正确放弃“所有权”。一台主机如何知道另一台主机已更改对象的状态?它必须——什么——再次复制回来?

“分布式对象”模型很快变得复杂。

最简单的服务意味着只有一台主机提供服务并维护状态。几十年来,关系数据库一直是这种服务模型的例证。与其他传统服务(即电子邮件、NIS 等)一样,

通过一台主机提供服务,副本之间不存在同步、不存在重复且复杂性非常有限。

“为什么我们应该在更高级别上制定如此程序性的东西”

你没有在更高级别上有程序性的东西。

您有一个具有多种方法的对象(提供服务的主机)。它是完全面向对象的。

一般来说,它是一个单例,这让生活变得非常简单。

Distributed object means what? Two copies of the same object which must be synchronized? two-phase commit to each change to the object? Complex.

Moving an object around the network from location to location? In this case, you've got to be sure that "ownership" is correctly relinquished. How does one host know the other has changed state on the object? It has to be -- what -- copied back again?

The "distributed object" model rapidly gets complex.

A service -- at it's simplest -- means that exactly one host offers the service and maintains state. Relational databases have exemplified this services model for decades. As do other traditional services (i.e., email, NIS, etc.)

With one host offering services, there's no synchronization among copies, no duplication and very limited complexity.

"why should we have something so procedural at higher level"

You don't have something procedural at a higher level.

You have an object (the host that offers the services) with multiple methods. It's perfectly object-oriented.

It's -- generally -- a Singleton, which makes life very simple.

亚希 2024-09-03 21:30:27

为什么要对立呢?分布式服务和分布式对象的概念即使不是完全重叠,也有很大的重叠(毕竟 SOAP 是对象访问协议)。 WCF 是通过一行配置在“Web 服务”和“远程对象”之间切换的一个示例。

差异主要是术语上的,由历史应用领域来解释。

(Szymon 早期写的内容基本相同)

Why the contraposition? Concepts of distributed services and distributed objects overlap greatly, if not entirely (and SOAP is object access protocol, after all). WCF is one example of switching between 'web service' and 'remote object' by a single line of configuration.

Difference is mostly terminological, explained by historical areas of application.

(Szymon wrote essentially the same eariler)

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