Scott Hanselman

Where did God put his readonly variables?

February 14, 2003 Comment on this post [3] Posted in Web Services
Sponsored By

I've got one more physics class and two math classes to finish my 11 year quest for a 4 year degree.  As I was sitting in Physics yesterday we were talking about the Ideal Gas Constant and Avogadro's number and the thousand other constants that make It All Work.  And I was thinking...in my programming I'm always trying to avoid superfluous constants when possible, and use enums to group related consts when possible. 

But in the Universe, for It All To Work we seem to need a lot of very precise and specific Constants and learning physics for me has been as much learning another person's code and algorithms as it has been understanding the constants they needed to get the job done.

My real question is, did God put these constants as a readonly field in a static constructor or a singleton pattern, or assuming parallel universes, a factory pattern? Either way, it makes me think when I write C# code, how would God write this loop? :)

(and please note God's use of a modified Hungarian naming convention)

public Reality
{
      public readonly double dblAvogadrosNumber = 6.022137*10^23....etc;
      /* additional Reality Code removed for clarity... */
      private static Reality singletonInstance;
      private static int cReference;
      public static Reality GetInstance()
      {
          if(singletonInstance== null)
          {
              singletonInstance= new Reality("Let there be light, etc");
          }
          cReference++;
          return singletonInstance;
      }          

}

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
February 24, 2003 2:44
woudn't there be a trytruecatchtrue block?
February 24, 2003 2:46
erm, that didn't render pretty. there should be curly braces whereever you see the word true. i guess i might re-word it as, "wouldn't there be a try-catch block?"
February 24, 2003 21:16
Lol that's pretty funny. I like this line of thought.

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.