Shared methods over WCF?

  • Thread starter Thread starter Ronald S. Cook
  • Start date Start date
R

Ronald S. Cook

I was thinking about the methods in our "service" project (business tier).
Is there any issue with implementing static (shared) methods over Windows
Communication Foundation (WCF)? If not, I think we should consider making
those methods shared. We don't maintain any state in the objects, so it
doesn't really make sense to me to instantiate an object in order to call a
stateless method on that object. Thoughts?

Thanks,
Ron
 
Ronald S. Cook said:
I was thinking about the methods in our "service" project (business tier).
Is there any issue with implementing static (shared) methods over Windows
Communication Foundation (WCF)? If not, I think we should consider making
those methods shared. We don't maintain any state in the objects, so it
doesn't really make sense to me to instantiate an object in order to call a
stateless method on that object. Thoughts?

I don't know what WCF is but if your objects don't keep any state then the
methods should most likely be static.
 
It depends on the scenario... a typical (per-call) WCF implementation
has the service contract defined by an interface, implemented by a
bespoke server class at the server, and by a proxy class at the
client. Static members can't implement interfaces; at the server you
could forward the methods to a static member, but to no benefit: you
already have an object (although it won't last much longer than the
call, and won't be taking much memory anyway).

Perhaps look into the singleton approach; all 3 common solutions are
discussed (briefly) here:

http://searchvb.techtarget.com/originalContent/0,289142,sid8_gci1225694,00.html

You might also want to look here, which discusses the implementation
of said:

http://www.vistax64.com/indigo/70593-multithreading-wcf-service.html
 
Back
Top