为什么CRUD操作在SOA设计中如此糟糕?[英] Why are CRUD operations so bad in a SOA design?

本文是小编为大家收集整理的关于为什么CRUD操作在SOA设计中如此糟糕?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我刚刚在 MSDN上读完了一篇文章.他猛击了骨头界面,称其为反图案.

我同意拥有任何状态的东西是困难而最新的,而moveNEXT是坏主意,但我不同意crud像创建读取更新和删除是不好的.如果我有汽车服务,并且我想让客户能够做到基础知识,例如在创建汽车中,获取汽车详细信息,更新汽车的详细信息或删除汽车,那么他们将如何能够做这些事情没有CRUD操作.

或我在这里缺少什么?

推荐答案

应该在分布式系统/SOA方案中避免CRUD接口,因为它们很健谈.但这并不意味着必须.当您有一些客户操作需要多次调用您的服务时,您就会知道您应该放弃CRUD方法并创建新的服务操作,以将这些呼叫一致单一呼叫一致.设计分布式系统时,您应始终将呼叫数量减少到最低限度,因为网络调用非常耗时.

编辑:

您可以将CRUD接口视为服务中的数据访问.有时您真的想要这个.但是,在SOA和分布式系统体系结构中,您通常正在揭露已经包装数据访问并提供更复杂操作的业务功能(这些数据访问操作).

示例:

crud x业务逻辑接口.假设您正在使用Invoices.每张发票由InvoiceHeader和一个或多个InvoiceLine组成.如果使用发票的CRUD接口,您将首先调用CreateInvoiceHeader操作以创建InvoiceHeader,然后几个AddInvoiceLine操作添加所有InvoiceLines - 这是低级别的CRUD方法.但是,如果您在服务方面实现业务逻辑,则将调用单个CreateInvoice,然后将复杂的对象图(带有所有行的标题)传递到服务以创建和添加所需的内容. Create方法还可以执行其他业务操作,例如启动一些工作流程等.这是常见的SOA和分布式系统方法.

其他推荐答案

restfull Web Services 最近获得了普及evdemon的帖子.

其他推荐答案

我认为他有目的地设计了最糟糕的接口,这并不是真正的crud接口.

<WebMethod()> _
Public Function MoveNext() As Boolean
End Function

<WebMethod()> _
Public Function Current() As Object
End Function

这两种方法显然不是无状态的,但是真正的CRUD接口也不需要.我认为这只是一个非常糟糕的例子,它与Crud操作并不相关.

更新:

找到了一个类似的问题,非常好 anders :) p>

本文地址:https://www.itbaoku.cn/post/627676.html

问题描述

I have just finished reading an article on MSDN by John Evdemon. He bashes the CRUD interfaces and calls it an anti-pattern.

While I agree that having ANYTHING stateful is difficult and Current and MoveNext are bad ideas I don't agree that CRUD as in Create Read Update and Delete are bad. If I have a car service and I want to let clients be able to do the basics, as in Create a car, get a cars details, update a cars details or delete a car then how are they meant to be able to do those things without CRUD operations.

Or what am I missing here?

推荐答案

The CRUD interfaces should be avoided in distributed system / SOA scenario because they are very chatty. But should doesn't mean have to. When you have some client actions which require more than one call to your service then you know that you should give up CRUD approach and create new service operation which will agregate those calls into single call. When designing distributed system you should always reduce number of calls to minimum because network call is very time consuming.

Edit:

You can think about CRUD interface as about data access exposed in a service. Sometimes you really want this. But in SOA and distributed system architecture you are usually exposing business functionality which already wraps data access and offers much more complex operations (which agregate many data access operations).

Example:

CRUD x Business logic interface. Suppose that you are working with Invoices. Each invoice consists of an InvoiceHeader and one or more InvoiceLine. If you use a CRUD interface for invoice you will first call CreateInvoiceHeader operation to create InvoiceHeader and then several AddInvoiceLine operations to add all InvoiceLines - that is low level CRUD approach. But if you implement business logic on the service side you will call single CreateInvoice and pass a complex object graph (header with all lines) to the service to create and add what is needed. The Create method can also do other business operations like starting some workflow etc. That is common SOA and distributed system approach.

其他推荐答案

RESTfull web services which have been lately gaining popularity are proving wrong Mr. John Evdemon's post.

其他推荐答案

I think he has on purpose designed the worst possible interface here and it is not really a CRUD interface.

<WebMethod()> _
Public Function MoveNext() As Boolean
End Function

<WebMethod()> _
Public Function Current() As Object
End Function

These two methods are obviously not stateless, but nor are they needed for a true CRUD interface. I think it just a very poorly written example and it is not really related to CRUD operations.

Update:

Found a similar question with a very good answer :)