Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The short answer: services should be designed for the convenience of the service client. If the client is told "call this, then cdon't forget to call that" you're making their lives too difficult. There should be a coarse-grained service.</p> <p>A long answer: Can a Customer reasonably be entered with no Address? So we call</p> <pre><code>createCustomer( stuff but no address) </code></pre> <p>and the result is a valid (if maybe not ideal) state for a customer. Later we call</p> <pre><code>changeCustomerAddress ( customerId, Address) </code></pre> <p>and now the persisted customer is more useful.</p> <p>In this scenario the API is just fine. The key point is that the system's integrity does not depend upon the client code "remembering" to do something, in this case to add the address. However, more likely we don't want a customer in the system without an address in which case I see it as the service's responsibility to ensure that this happens, and to give the caller the fewest possibilities of getting it wrong.</p> <p>I would see a coarse-grained createCompleteCustomer() method as by far the best way to go - this allows the service provider to solve the problem once rather then require every client programmer to implement the logic. </p> <p>Alternatives:</p> <p>a). There are web Services specs for Atomic Transactions and major vendors do support these specs. In principle you could actually implement using fine-grained methods and true transactions. Practically, I think you enter a world of complexity when you go down this route.</p> <p>b). A stateful interface (work, work, commit) as mentioned by @mtreit. Generally speaking statefulness either adds complexity or obstructs scalability. Where does the service hold the intermediate state? If in memeory, then we require affinity to a particular service instance and hence introduce scaling and reliability problems. If in some State or Work-in-progress database then we have significant additional implementation complexity. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload