Use of Static

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I am creating a few services on a application like MembershipService,
TwitterService, etc ...

As far as I know services in .NET, well at least in ASP.NET, are
usually static.

Should I make the services classes static?

And I suppose the services methods need and should be static to.
Correct?

Thanks,
Miguel
 
Hello,

I am creating a few services on a application like MembershipService,
TwitterService, etc ...

As far as I know services in .NET, well at least in ASP.NET, are
usually static.

Should I make the services classes static?

And I suppose the services methods need and should be static to.
Correct?

Thanks,
Miguel

I'm not entirely sure what you mean, but to answer your question, that
is up to you. You can make your service classes static or non-static.
It depends on if you want to force everything to move through one
object, or if you are comfortable creating instances of your objects
for each request. It really depends on what you are trying to
accomplish.
 
I would NOT make a service static as it really goes against what a service should be. A service should provide a way to share resources as well as a common interface: defining them as static could introduce weird behaviors down the road (e.g. one call to a service potentially changing the state of another call... a little bit like pulling a rug from under someone's feet).

Olivier



shapper wrote:

Use of Static
27-Aug-09

Hello

I am creating a few services on a application like MembershipService
TwitterService, etc ..

As far as I know services in .NET, well at least in ASP.NET, ar
usually static

Should I make the services classes static

And I suppose the services methods need and should be static to
Correct

Thanks
Miguel

EggHeadCafe - Software Developer Portal of Choice
Consuming WebServices with SSL and HTTP BASIC Authentication
http://www.eggheadcafe.com/tutorial...a-b4eac36067e8/consuming-webservices-wit.aspx
 
Olivier Steck wrote in
I would NOT make a service static as it really goes against what a
service should be. A service should provide a way to share resources
as well as a common interface: defining them as static could introduce
weird behaviors down the road (e.g. one call to a service potentially
changing the state of another call... a little bit like pulling a rug
from under someone's feet).


I agree, unless the OP is also creating some "helper" classes that he is
calling a "service".

Peace and Grace,


--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Back
Top