Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes. If the methods are all static, then no instances are going to be on the managed heap. Every time you call, you will reference the type directly and access it's members without allocating memory on the heap.</p> <p>If you have an instance class, then every time you create an instance, you would incur a cost on the heap. If you're also not holding on to a reference, then you're going to have a high churn in generation 0 of the CLR. This assumes you will be creating a great deal of objects to make these calls.</p> <p>Of course, if you are implementing <a href="http://en.wikipedia.org/wiki/Singleton_pattern" rel="nofollow">the singleton pattern</a> then the cost will be small, as you're only going to implement a <em>single</em> instance of your object.</p> <p>However, this is all moot, as it's a <a href="http://www.codinghorror.com/blog/2009/01/the-sad-tragedy-of-micro-optimization-theater.html" rel="nofollow">micro optimization</a>; unless you find yourself creating an exorbitant amount of these objects to perform this function and through profiling it's determined that you actually <em>have a problem</em>, then it should be a matter of whatever is easiest to maintain.</p> <p>I will say though, that if a method is stateless and it naturally looks like it would operate off an existing type then I will typically write an <a href="http://msdn.microsoft.com/en-us/library/bb383977.aspx" rel="nofollow">extension method</a>; it's a static call, but gives the appearance of an instance call, which to some (and me personally) has a much nicer flow in code than calling a static method directly off the type (especially when it enables me to design a <a href="http://en.wikipedia.org/wiki/Fluent_interface" rel="nofollow">fluent interface</a>).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload