Scott Hanselman

Where did God put his readonly variables?

February 14, '03 Comments [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
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb
Sunday, February 23, 2003 10:44:52 PM UTC
woudn't there be a trytruecatchtrue block?
Sunday, February 23, 2003 10:46:03 PM UTC
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?"
Monday, February 24, 2003 5:16:49 PM UTC
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.