tags:

views:

293

answers:

2

We're using about 7 services at the moment. There quite large.

Does anyone have any experience with the single responsibility principle and WCF services? Does this mean that you'll end up with lot's of small contracts? If so, how do you manage these in your application?

A: 

I would suggest you listen to this podcast on the hanselminutes :

SOLID Principles with Uncle Bob - Robert C. Martin

It would help understand things better. . .

Jomit
I did ;) It actually made me explore the single responsibility principle to see if it's worth the effort of changing our project. I like all the small examples of rectangles and square and stuff, but how does it work in real life?
Sorskoot
+2  A: 

I think you are confusing single responsibility with interface segregation.

From the client/service interface perspective, you should keep your contracts lean and mean. See below for an example of that.

On the SRP side of things, that should be entirely internal to the service implementation and the client should not be aware of this. If you service code is too large, split it up into classes. Then have your service code, at least initially, act as a facade and forward all the calls to the relevant objects. Later on, you have the option of spliting your service into multiple services. But be aware, that SOA and object oriented design, although overlap, are separate and have different requirements.

Interface segregation example: We have a service here at work that we use to do various functions on some business objects. The original service had one interface. As it grew, we realized we had three family of methods: data object persistence, business updates, business analysis. We split up into three contracts. Our client/service implements all 3, so the only thing we had to do was split the contract into three and setup two additional endpoints in our WCF configuration. Very simple.

Hope this helps.

siz