Hello,
I know that the kind of question below has been asked several
times....howeve r I need a clear answer in my specific situation.
I have 2 methods. One returns an SqlDataReader and the other returns a
DataView. I was considering making them Static methods, so as to avoid
creating instance of the class which takes care of these methods, kind
of a helper class. Since its a web site the method may be accessed by
more than one user at one time....
the question is would it improve the performance if using Static method
in this case? Would it be a problem if using Static methods at all?
Thanks! 4 2163
As long as your methods don't rely on any static fields global to the class
you'll be ok.
Yes it'll probably improve performance, but there are probably 100 things
you could do that'll improve it more. Seems like a pretty minor performance
improvement.
Karl
-- http://www.openmymind.net/ http://www.codebetter.com/
"Varangian" <of****@gmail.c omwrote in message
news:11******** *************@4 2g2000cwt.googl egroups.com...
Hello,
I know that the kind of question below has been asked several
times....howeve r I need a clear answer in my specific situation.
I have 2 methods. One returns an SqlDataReader and the other returns a
DataView. I was considering making them Static methods, so as to avoid
creating instance of the class which takes care of these methods, kind
of a helper class. Since its a web site the method may be accessed by
more than one user at one time....
the question is would it improve the performance if using Static method
in this case? Would it be a problem if using Static methods at all?
Thanks!
"Varangian" <of****@gmail.c omwrote in message
news:11******** *************@4 2g2000cwt.googl egroups.com...
I know that the kind of question below has been asked several
times....howeve r I need a clear answer in my specific situation.
I have 2 methods. One returns an SqlDataReader and the other returns a
DataView. I was considering making them Static methods, so as to avoid
creating instance of the class which takes care of these methods, kind
of a helper class. Since its a web site the method may be accessed by
more than one user at one time....
Static methods which return ADO.NET objects are quite common in DALs
(database abstraction layers) - see the Microsoft DAAB for examples of
this...
the question is would it improve the performance if using Static method
in this case?
Not really - in fact, probably not at all...
Would it be a problem if using Static methods at all?
No, so long as you realise that any static variables will be shared across
multiple instances. This may or may not matter... E.g. if your site uses
only one SQL connection string, then it won't matter if it's shared across
multiple instances, as it will always be the same... However, if you have
other static variables which differ per session, then you will have serious
problems... :-)
All my DAL methods are static because it's a bit less coding not to have to
do class instantiation every time...
Thank you for the reply.. I have a better understanding of static stuff
in ASP.NET
Mark Rae wrote:
"Varangian" <of****@gmail.c omwrote in message
news:11******** *************@4 2g2000cwt.googl egroups.com...
I know that the kind of question below has been asked several
times....howeve r I need a clear answer in my specific situation.
I have 2 methods. One returns an SqlDataReader and the other returns a
DataView. I was considering making them Static methods, so as to avoid
creating instance of the class which takes care of these methods, kind
of a helper class. Since its a web site the method may be accessed by
more than one user at one time....
Static methods which return ADO.NET objects are quite common in DALs
(database abstraction layers) - see the Microsoft DAAB for examples of
this...
the question is would it improve the performance if using Static method
in this case?
Not really - in fact, probably not at all...
Would it be a problem if using Static methods at all?
No, so long as you realise that any static variables will be shared across
multiple instances. This may or may not matter... E.g. if your site uses
only one SQL connection string, then it won't matter if it's shared across
multiple instances, as it will always be the same... However, if you have
other static variables which differ per session, then you will have serious
problems... :-)
All my DAL methods are static because it's a bit less coding not to have to
do class instantiation every time...
You may see some performance increase due to not having to instantiate
objects. I ran a comparison test onetime of a very simple db object. All
this class did was create a user in a custom membership system. I ran
through a loop and found that the loop crashed due to the GC not being fast
enough to clean up the destroyed objects. When I tested the same using a
static method to do the database activity I was able to run over 15 times as
many loops (finally stopped simply because I didn't need any more bogus
users) and this was just with a simple insert.
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
"Varangian" <of****@gmail.c omwrote in message
news:11******** *************@4 2g2000cwt.googl egroups.com...
Hello,
I know that the kind of question below has been asked several
times....howeve r I need a clear answer in my specific situation.
I have 2 methods. One returns an SqlDataReader and the other returns a
DataView. I was considering making them Static methods, so as to avoid
creating instance of the class which takes care of these methods, kind
of a helper class. Since its a web site the method may be accessed by
more than one user at one time....
the question is would it improve the performance if using Static method
in this case? Would it be a problem if using Static methods at all?
Thanks! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steven D'Aprano |
last post by:
I've been doing a lot of reading about static methods in Python, and I'm
not exactly sure what they are useful for or why they were introduced.
Here is a typical description of them, this one from Guido:
"The new descriptor API makes it possible to add static methods and class
methods. Static methods are easy to describe: they behave...
|
by: baylor |
last post by:
In C#, an interface cannot mark any method as static. i'm told the ILASM
supports it but i've never tested that
Two questions. First, why? OK, i've heard the reason about interfaces being
allocated on the stack but that's not a real reason. Which is OK because this
isn't a real question, it's just a complaint dressed up to look like a reason...
|
by: Daniel Gustafsson |
last post by:
Hi there, hmm, I've just started with C# and I'm experimenting with method
overloading.
It seems like it's not possible to override method using return types, only
parameters. Is that by design, anyway around that or something? I.e. I'd
like to have the same method return either a DataReader or a DataAdapter
depending on the lvalue when...
|
by: Peter Lin |
last post by:
Dear all,
I am using Microsoft.ApplicationBlocks.Data, for one thing I am not quite sure.
Is the following static SqlHelper ExecuteReader method from source codes not thread saft in
multithread environment?
Do we need to use lock or monitor to protect our data in the static method
in multithread environment?
Do the following codes have the...
|
by: Paschalis Pagonidis |
last post by:
Hi,
I have a class which all its attributes, properties and
methods are static.
However, I want a method to return an object that should
be non-static.
Is that possible?
| |
by: Laban |
last post by:
Hi,
I find myself using static methods more than I probably should, so I am
looking for some advice on a better approach.
For example, I am writing an app that involves quite a bit of database
operations on purchase orders and inventory. I have created a PurchaseOrder
class and Inventory class to encapsulate operations like creating POs,...
|
by: Lerp |
last post by:
Hi all,
With regards to calling data from a database and filling in an editing form
based on some query, which is the best (least intensive on processor) method
for assigning the returned results to a variable.
I have been using a couple of ways so far in my project.:
1. strFirst=objDR("Fname")
2. strFirst=objDR.GetOrdinal("Fname")
|
by: Mirek Endys |
last post by:
Hello all,
another problem im solving right now. I badly need to get typeof object that
called static method in base classe. I did it by parameter in method Load,
but i thing there should be way, how to get this information in called
method.
Thanks.
public abstract class BaseClass
{
|
by: TRScheel |
last post by:
Platform: Windows Vista
Language: ASPX / C#
I am trying to make a business library for where I work, and I have everything figured out and done except for the ObjectDataSource portion.
If any of you have used the ObjectDataSource, it binds to a static (you could bind it to a class that isnt static, but then the values and items within that...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |