问题描述
限时送ChatGPT账号..目前我正在创建一个 WCF 服务,它必须连接到一个 DAL,它只使用 ADO 和存储过程连接到一个数据库.
Currently I am creating a WCF service which has to connect to a DAL which, just connects to a database using ADO and stored procedures.
DAl 将其响应从数据库写入数据契约,该数据契约通过网络通过服务传递到客户端.
The DAl writes its responses from the database to a datacontract which is passed over the wire to the client via the service.
我读到这可能是反模式CRudy Interface",但我不确定,因为我正在共享数据合同.
I was reading that this may possibly be the anti pattern 'CRudy Interface', but I wasn't sure as I am sharing the datacontract.
如果我使用的是反模式,谁能建议一个更好的模式来用于我需要的行为?
If I am using an anti pattern, can anyone suggest a better pattern to use for the behavior I require?
推荐答案
好吧,对于 CRUDy 模式及其优缺点似乎存在一些争议.至少,我会调用一个服务接口,让你编写这种代码来使用它的反模式(如评论 此处):
Well, there seems to be some controversy about the CRUDy pattern and it's pros and cons. At a minimum, I would call a service interface that makes you write this kind of code to use it an anti-pattern (as commented here):
service.CreateCustomer(c);
foreach(Group group in c.Groups)
service.AddCustomerToGroup(c.CustomerId, group.GroupId);
foreach(Person person in c.Contacts)
service.AddCustomerContact(c.CustomerId, person);
暴露 CRUDy 接口本身就不好吗?我不会这么说.重要的是提供一个接口,该接口将
Is exposing CRUDy interfaces bad in itself? I wouldn't say so. What's important is to provide an interface which will
封装有关底层流程的知识不要太健谈这篇关于这是 Crudy 的反模式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论