473,320 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

static method against class method

I have a static class with bunch of static methods. That is my common
routines used spratically across the programs. I am wondering which is
the best coding and performance wise good standard. Try to put the
required methods in a class and use the class or keep the static on
most commonly used methods?

Thanks.

Sep 1 '06 #1
2 1175
As always it depends ...

Do they share any kind of state? Then a class would be good.
Are the method non-reentrant? Then a class would be good (links to item #1)
Do you want to ever use polymorphism? Then a class would be good

If you answerred no to these cases .. Then a static class works well
conceptually and you are left with a design preference :)

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
"DBC User" <db*****@gmail.comwrote in message
news:11**********************@74g2000cwt.googlegro ups.com...
>I have a static class with bunch of static methods. That is my common
routines used spratically across the programs. I am wondering which is
the best coding and performance wise good standard. Try to put the
required methods in a class and use the class or keep the static on
most commonly used methods?

Thanks.

Sep 1 '06 #2
As you said, they are static. Keep things static if they don't need any
state. Things become simplier as you don't need to worry about state
leaking in, and you can just call them anywhere in your app without init().

--
William Stacey [MVP]

"DBC User" <db*****@gmail.comwrote in message
news:11**********************@74g2000cwt.googlegro ups.com...
|I have a static class with bunch of static methods. That is my common
| routines used spratically across the programs. I am wondering which is
| the best coding and performance wise good standard. Try to put the
| required methods in a class and use the class or keep the static on
| most commonly used methods?
|
| Thanks.
|
Sep 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: lawrence | last post by:
To call I would do something like: $headline = McSelectJustOneField::callDatastore("cbHeadline"); Is this the correct use of the static keyword, to implement a Singleton design?
13
by: Axehelm | last post by:
Okay, I'm in a debate over whether or not static methods are a good idea in a general domain class. I'm personally not a fan of static methods but we seem to be using them to load an object. ...
4
by: Paul MG | last post by:
Hi I have been in the habit, when extracting a private "helper" method from a public method, of marking it "static" wherever possible -- that is, when it does not reference instance variables or...
1
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...
7
by: Sunny | last post by:
Hi all, According C# Language Specification : 10.11 Static constructors: The static constructor for a class executes at most once in a given application domain. The execution of a static...
10
by: Marek | last post by:
Hi, I am analyzing Duwamish7 source code boundled with Visual Studio .NET 2003. Could anoybody explain why the Monitor.Enter and Monitor.Exit block is used inside a static constructor? The code...
10
by: McFly Racing | last post by:
Thread Locking In Static Methods I have the need for a Log Manger class that has static methods. Normally I would use the lock statement or a Monitor statement both of which take a...
3
by: Bob | last post by:
I have an abstract class Thing which has a static method Thing GetThing(). Class Something inherits from Thing. SomeThing supplies static info for GetThing to get stuff from the database to create...
6
by: Marek | last post by:
Hi, I am analyzing Duwamish7 source code boundled with Visual Studio .NET 2003. Could anoybody explain why the Monitor.Enter and Monitor.Exit block is used inside a static constructor? The code...
6
by: ketan | last post by:
Hi All, I have a situation where in I need to call static methods of the derived class. I checked previous posts, but could not get any satisfactory reply. My situation can be simulated with...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.