I am currently working on a WCF service with a large number of methods defined in the interface. Most of these methods are simple CRUD operations with a bit of logic using entity framework, and could be split into functional areas pretty easily. There's only a single file that is approaching 1K lines of code and I would like to split it up for maintainability. I am considering the following:
Also, would it be better to split by functional area, or by CRUD methods (group all gets together, creates together, etc).
This must be a very common issue when dealing with WCF services. What is a good way to organize WCF service methods?
Update
In the end, I decided to pass the service calls to internal static classes.
If operations can be grouped by functional areas they should be separate services because service as any other class should have single responsibility = single functional area.
Generally if your service has a lot of operations it is time to thing about its splitting. Also most often WCF service is only wrapper around some logic so you can create instances of other classes wrapping your logic or use static classes in your service operations.
Edit:
Generally I'm against using partial classes to break a big class - in my opinion it doesn't improve maintainability. Once a class is so big that you are looking for solution to break it into multiple files it already means that refactoring should have been done long ago. In the worst case when your class is doing really too much we can call it anti pattern: God object.
For maintainability, using partial classes would seem to be a good option. If they are split functionally, then the maintainability is improved becasue you should only need to look at one or two of these classes.
The fact that there is still one huge class with many methods is not really a problem on the basis of your answers. It should be maintainable.
But, to follow @Ladislav, is there any value to you in separating them out into separate services? I assumed not, otherwise you would have done that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With