views:

177

answers:

2

I have built a complex query mechanism which I want to provide a factory for in order to assist people with common query patterns. My methods are all revealed via WCF as a SOAP web service. What is the best way to ensure that my factory is easy to use across all clients that may wish to use my service (as I don't expect all of my customers to use .net)?

Update: I want to write some factory methods to assist with common patterns against a "query system" that I have written. I have currently multiple OperationContracts exposed from my Service and multiple DataContracts exposed as well. I'm having a mental block as to the best way to build something of a Factory to return my custom query objects to support common patterns that I am assuming they desire.

A concrete example of this is would be one method returns hits on my database based on a search request object that has multiple groups of multiple match concepts, my code translates all of this into LINQ expression trees, one common group in this search request object would be to limit the results to just sources of US origin, which is actually a group of about 20 matches and can shift, so instead of showing a hard-coded code example, I'd prefer to just return the group object based on the data about where the items were sourced which they can then use in their search request object. This sounds ideal for a Factory Method like "GroupFactory.CreateGroupOfSomethingOrOther", but what is the best place for me to do this? Or am I just making this far more complicated in my mind than it should be?

+1  A: 

Follow-up question: Are you saying you want to expose the factory methods over WCF and return a query object? I'm a little unclear about what you are trying to do...

James Bender
Added 2 paragraphs to the question.
Kearns
I'm sorry but I'm still not understanding what you are tring to do. Are you trying to take a Factory and turn it into a WCF service?
James Bender
A: 

You cannot really provide factories unless you provide libraries for each of your consumers in their native languages. Instead of a factory that returns a grouping object, consider filter adding some filter objects that require less granular configuration.

For example, instead of:

GetMatches(new GetMatchRequest() { Filter = new FilterByState() { "AZ", "CA", "OH", ... });

Consider:

GetMatches(new GetMatchRequest() { Filter = new FilterByCountry("USA") });

Where all common filters derive from something like FilterBase or implement IFilter. On the server side, call something like FilterBase.ConstructQueryObject() to return the more granular objects.

jezell