Welcome to MSDN Blogs Sign in | Join | Help

My travels with WDF

The continuing story of a boy, his dog and their discovery of the world outside...of WDM.
You have to pass third before going home.

All forces occur in pairs, and these two forces are equal in magnitude and opposite in direction.

This is Newton's third law of motion.

This is Patrick's first law of programming.

The thing I've been bitten with more than any in my "life" at, and before, Microsoft are bugs related to the releasing or freeing or generally UNDOing something I did earlier in code.  Acquire a CriticalSection.  Forget to free it in some weird error path you never expect to hit, until you hit actually hit it.  Allocate a hunk of memory, forget to free it somewhere you never expect to hit, until you hit it.  Take a ref count, forget to release it somewhere (you know the rest).  So over the years, I have adapted my code monkey style to follow some rules in other disciplines of science that tend to lend themselves to computer science (and some of these are really axioms for just about everything you do in daily life).

So in this particular exmaple, it is Newton's Third Law.  For every action, there is an equal and opposite reaction.  For every allocate, there is a free, for every InitializeCriticalSection, there is a DeleteCriticalSection and so on...

I've tried to explain to my wife that this follows daily life as well, for every upward flip of the light switch, there is a downward flip, for every rightward twist of the stove nob, there is an equal leftward twist, etc.  Needless to say that doesn't go over well, but the small upside here is our couch is very comforatble. 

So I tend to keep my little crazy "laws" to my work.  I almost always try to take some additional steps to ensure that every time I do something in code that has an "action" in the API, there is an undo action later in the code.  And then, I also try to make sure that undo action is reachable by every exit path.  Save that one time I wrote a test that I forgot to actually allocate memory for an object before using it....which I just ran in to yesterday.  That my friends is a very loose variant of De Morgan's law being applied to Newton's Thrid Law which was adapted to be Patrick's First Law of Programming. Got that? :)

On a personal note, I spent roughly 1.5 hours in the dentist chair today.  Last week a chunk decide to take its leave of my 2nd molar.  It wasn't a big piece, maybe the size of head from a shirt pin, but it was enough for my dentist to give me the "good news, bad news" speech after the x-rays were finished.

Good news; Your tooth is strong and healthy overall.  The piece that departed did not cause a crack.  It was really just one of the grindy bits on the top of the tooth.

Bad news; We can't just repair it because it is a terminal molar, and the structural integrity of the repair would not be sufficient enough to withstand normal usage. 

I had spent a couple of days worrying that he would have to extract the tooth.  And this was mostly because the last time anybody (same dentist) tried to extract one of my 3rd molars (a.k.a. wisdom teeth), I blacked out in the chair.  Not from pain or anything, but just from being a big chicken (so he says.  I say it was lack of food, adrenaline and my superb "fight or flight or pass out" reactions).  Long story short, I have a temporary crown in place of my 2nd molar.  

Let me tell you, there is something really, really weird about hearing and feeling a substantial, mechanized grinding in your mouth.  Not the normal cavity drill, this was a full on super thick grit drill bit.  Something you would normally hear when people are drilling through rock.

So about 2 hours later I was home, half of my mouth tingly and slightly sore, but my full mouth had a horrible medicine taste that even an good dose of Red Hook Blonde Ale could not cure.

None of this really has to do with WDF, but it's 23:30, I've been taking OTC pain relievers and my jaw still really hurts.  Not my tooth, my jaw.  You sit there for 1.5 hours with your mouth wide open, people poking and pulling around in there like they're trying to get a hook out of a large mouth bass, and then tell me it doesn't hurt aftewards.

Worst part is, I know tomorrow it'll be my tooth that hurts.

*hrmpf*

Posted: Thursday, October 18, 2007 10:49 PM by patman
Filed under:

Comments

No Comments

Anonymous comments are disabled
Page view tracker