Is this the Crudy anti pattern?

后端 未结 3 578
猫巷女王i
猫巷女王i 2021-01-20 03:15

Currently I am creating a WCF service which has to connect to a DAL which, just connects to a database using ADO.net and stored procedures.

The DAl writes its respon

3条回答
  •  无人及你
    2021-01-20 03:18

    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);
    

    Is exposing CRUDy interfaces bad in itself? I wouldn't say so. What's important is to provide an interface which will

    1. encapsulate knowledge about the underlying processes
    2. not be very chatty

提交回复
热议问题