Linked Questions
13 questions linked to/from Performance of static methods vs instance methods
7 votes
3 answers
3k views
Better way to call Function multiple times [duplicate]
In OOP such as C# and Java if I were to create a class to do all string manipulation, I know it is better to make all the function static. However when I need to call those functions multiple times, ...
3 votes
2 answers
2k views
Static class vs Class with constructor performance [duplicate]
Performance-wise is there any difference on doing this?: public static Class StaticTestClass() { public static void Function(object param) => //Do stuff with "param" } and this: public ...
3 votes
1 answer
367 views
Using static classes or not in an object that has many instances for memory/performance benefit? [duplicate]
Would there be a difference in performance or memory if I used static classes in an object that has many instances? Let's say I have thousands of instances and each is responsible for doing many ...
427 votes
14 answers
89k views
Method can be made static, but should it?
ReSharper likes to point out multiple functions per ASP.NET page that could be made static. Does it help me if I do make them static? Should I make them static and move them to a utility class?
34 votes
7 answers
24k views
Performance of using static methods vs instantiating the class containing the methods
I'm working on a project in C#. The previous programmer didn't know object oriented programming, so most of the code is in huge files (we're talking around 4-5000 lines) spread over tens and sometimes ...
32 votes
2 answers
21k views
Are static methods always held in memory?
My whole development team thinks, static methods are a terrible thing to use. I really don't see any disadvantages in some cases. When I needed a stateless method before, I always used static methods ...
8 votes
6 answers
16k views
What is the difference between static functions and function outside of a class in PHP?
I need to have method to get something from a database, but I don't understand the difference between static and normal functions in PHP. Example code class Item { public static function ...
2 votes
2 answers
300 views
C# recurring class instantiation unnecessary?
I have the main class: class MainClass { public static void Main() { InputForm InputForm1 = new InputForm(); InputForm1.ShowDialog(); // show interface to prompt user } } ...
0 votes
1 answer
674 views
Static method vs non static method performance in Java with object creation
I am not too familiar with Java. I have the following question. I have seen similar posts on SO on this. What I am asking may be a bit different. If I have the following situation public class A { ...
1 vote
3 answers
140 views
Static Method in Instances
Straight up question: If I run code analysis, it tells me to make methods static even in nonstatic classes. As far as I know, static methods are JITed and run on the Type-Object in the Heap. So wouldn'...
0 votes
1 answer
152 views
Static or non-static class?
I currently am working on a project(Console Application) that consists of a number of classes. None of these classes contain any properties. They just contain a number of methods. Example: Say I ...
0 votes
0 answers
88 views
Is there a difference in performance between accessing properties of static and non-static class?
I'm just wondering whether there is any difference in performance for accessing properties of a static instead of non-static class? Let's say I have to classes private class Book1 { public const ...
0 votes
0 answers
50 views
Do I need to use static methods instead of non-static ones when having tons of instances of the class?
I Have a class called car, this class have multiple methods (about 30) to handle things such: starting car, stopping, opening doors ... The problem is that my program have thousands of instances of ...