CRUD Operations in SOA:
Context to this question can be found here: Why are CRUD operations so bad in a SOA design?
I am working on an interface - Ex: Order, in which I have CreateOrder, UpdateOrder and GetOrder methods. The Order also has OrderLines. As I do not want CreateOrderLine, GetOrderLine as separate methods, I do those tasks through the CreateOrder and GetOrder methods. For a delete and an Update, the Update method should be called. But I am trying to work out a pattern for deleting a specific OrderLine. How do I work out the difference between an Update and a Delete? I have the following thoughts on how to achieve DeleteOrderLine:
Method 1:
1a: If you want one Order Line deleted: - Populate all the OrderLines in the request except the one the one(s) that you want deleted.
1b: If you want one order line updated: - Populate all the OrderLines in the request, with new values for the ones that you want updated.
2 Call UpdateOrder 3 The implementation deletes all OrderLineItems before starting any processing and always adds the Lines as if they were new.
Method 2: - Add some sort of 'command' to each order line ('Add','Delete','Update') which the implementation can use to perform an appropriate action. - For updates, mark the lines that need to be updated with the 'Update' command. Only these get updated. - For deletes, mark the lines that need to be deleted with the 'Delete' command. Only these get deleted.
Does anyone have any other ideas or mechanisms to make this work?
Thanks.