Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Static Data Controller 1

Status
Not open for further replies.

timmoser

Programmer
Aug 31, 2002
41
US
Is its safe to create static level methods to handle database access?

DataAccessor.GetDataSet("spName",params);

Or should these be instance methods?

DataAccessor da = new DataAccessor();
da.GetDataSet("spName",params);

I created a class to remove some of the complexities of the data access layer (I think this would be the "Data Controller" layer:thread678-1121478). This class requires an instance to be used, but now I am experimenting with making the methods static. But I'm a little concerned with running into conflicts because a lot of applications are going to be using this class.

Is it good idea to create static methods for this type of work?

Thanks


If we're going to do it wrong we might as well do it wrong the right way.
 
You shouldn't have any problems, as long as you're not accessing any variables that weren't either passed to you as parameters, or created locally. If you do that, you may have some threading issues. :-(

Accessing local variables and parameters is safe even when multiple callers are using your method because they each get their own call stack frame, where the locals are stored.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Thanks that's what I was looking for.

If we're going to do it wrong we might as well do it wrong the right way.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top