Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Shared member - performance

0 views
Skip to first unread message

Sriram

unread,
Mar 2, 2004, 10:01:08 PM3/2/04
to
Hi,

We are using general DAL class for all common DB routines. That class has many shared member functions which can be called without instantiating the class. My questions, in a multiuser environment, as there is no instantiation involved for this class, how the function calls are processed? Will there be any performance issue? I have seen many MSDN code examples uses public shared function for common routines and so wondering whether it is right way for multiuser environment.

thanks in advance
Sriram

Michael Giagnocavo [MVP]

unread,
Mar 3, 2004, 8:39:54 AM3/3/04
to
You shouldn't normally think about using static (shared) methods just for a
performance gain, esp. where any difference at that level is insignificant
to accessing a database or likewise.

The difference between a static and instance methods is that instance
methods take an extra argument (this, or in VB "me"). So if you did a
static member that took an instance of its type as arg0, you'd have
something very similar to an instance method. The design issues (being able
to override methods) is much more important.

You do need to make sure that your static methods are threadsafe. For
instance, you shouldn't have a static method that changes a static variable
(for instance, in a DAL, storing the command in a static variable would be
bad), unless you use lock (SyncLock in VB). Using a lock to syncronize your
threads could create a performance problem. However, so long you stick to
locals and arguments, you're fine.

-mike
MVP

"Sriram" <anon...@discussions.microsoft.com> wrote in message
news:F8A1DE67-117C-475D...@microsoft.com...

0 new messages