Are shared methods slower ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I use shared methods for all my business logic classes to save typing when
calling them (because I would not need to instantiate the object). So I would
use them like this : "dim ds as dataset = Employees.List".

Is this ok or does this affect performance ?

Thanks, Craig
 
It depends on the size of the solution. Shared methods should actually be
faster, as they only have to load once and do not incur object instantiation.
But, you can overdo this and end up using a huge amount of memory. If you get
to this point, you can degrade perf.

Overall, helper methods are static (ie, those methods that have no object
context, like methods to add number, retrieve generic data, etc.). If you
have an object, its own methods should be non-static (instance methods). If
you follow the "rules" you are unlikely to go wrong.

I am very fond of making helper methods static, but I would not make
everything static. While you may end up with a perf benefit, you knock
maintainability out the window. You also can end up screwing up other aspects
of development.

FYI: Too many people focus on perf to the exclusion of other aspects:
maintainability, security, availability, etc. It is not a wise decision.

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

***************************
Think Outside the Box!
***************************
 
Back
Top