Question

I am looking to make some changes to an existing WCF service. I wanted to know if it would be best to make super methods such as a Save() that would use the values received to decide what action to take or if I should break the actions out into their own methods and expose those for the consumer to decide when to call them.

For instance, I have a payment handler that receives notifications from our merchant when they make a payment attempt and its results. Would it be better for me to allow the handler to pass in the object with a status change and let the super method attempt to figure out what to do with it (assuming no bugs have messed the data up) or create a separate method to extend so the intention is clearly defined.

Note that the super method is also responsible for saving data and changing status along other steps in the process.

I have googled around but haven't really found anything specific. To me the super method violates SOLID but I was told WCF has a different set of standards and its best to make super methods so the consumers don't have to think.

Any feed back is welcome :)

Was it helpful?

Solution

I find that it's best if service operations can exist at a level where they have business meaning.

What this means is that if a business person was told the operation name, they would understand roughly what calling that operation would do, and could make a guess at what data it would require to be passed to it.

For this to happen your operations should fulfill in full or in part some business process.

For example, the following operation signatures have business meaning:

void SolicitQuote(int brokerId, int userId, DateTime quoteRequiredBy);

int BindPolicyDocument(byte[] document, SomeType documentMetadata);

Guid BeginOnboardEmployee(string employeeName, DateTime employeeDateOfBirth);

If you use this principal when thinking about service composition then the benefit is that you will rarely stray far from the optimal path; you know what each operation does and you know when an operation is no longer needed.

An additional benefit is that because business processes change fairly rarely you will not need to change your service contracts as much.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top