Overhead of Shared Subs

  • Thread starter Thread starter Mick Walker
  • Start date Start date
M

Mick Walker

Hi All,

I am just wondering, is there some sort of overhead involved in shared
or static functions and subs?

I think there must be, otherwise, there would never be any need to
create an instance of a class to call one of its member methods., but I
would like to know for definate.


Regards
Mick
 
Whether there is overhead involved or not should not play a role in using
static/shared functions versus object methods. A method on an "automobile"
class to set the number of wheels, is probably static/shared. All
automobiles share this characteristic. A method for paint color is probably
not shared, as each automobile may be different colors.
 
ModelBuilder said:
Whether there is overhead involved or not should not play a role in using
static/shared functions versus object methods. A method on an "automobile"
class to set the number of wheels, is probably static/shared. All
automobiles share this characteristic. A method for paint color is probably
not shared, as each automobile may be different colors.
OK and how about a situation where I am implimenting my Business Logic
through the use of a class?

i.e Public Shared Function InsertUser(....)
Public Shared Function GetUserDetials(....) ...

etc

Whould there be any additional overhead involved in this menthod, than
if they were not shared, and I created an instance of this class and
thus called the methods?
 
Mick said:
I am just wondering, is there some sort of overhead involved in shared
or static functions and subs?
No.

I think there must be, otherwise, there would never be any need to
create an instance of a class to call one of its member methods., but I
would like to know for definate.

You are not thinking object oriented, that's why you don't see the
difference.

Instance methods of a class are non-static because they use the data
that is stored in the instance. You create the instance to keep data in
it, not only to call it's methods.

A method that does not use any data from the instance should be static,
so that you don't need to create an unused instance just to call the method.
 
Back
Top