Monday, October 27, 2003

A Retratction

Recently, I mentioned that I thought the Microsoft Application Blocks were not mature. I sited a general documentation bug and a Configuration Management Application Block threading bug as key indicators that the software isn’t ready for prime time. And I said that I hadn’t heard back from them after reporting the bug.

Well, I’m going to eat my words on two of those: the threading bug doesn’t exist, and not only did the Patterns and Practices group get back to me, the email was written before I posted the blog entry…I just hadn’t checked that particular email inbox that day. And the team is aware of the documentation bug and plans to fix it.

For the record, the threading bug I thought I saw was related to a Hashtable maintained in the MemoryCache class. I noticed two things about it: First, that they weren’t using the Synchronized wrapper. Second that even though they were taking a lock on writes, they weren’t locking on reads. This is not, in general, safe to do. In particular, it’s not safe to enumerate over a Hashtable at the same time a write is occurring.

As it turns out, the CMAB implementation is safe because they never enumerate over the collection. And since the Hashtable is a private field, no one else can, either. Not using a Synchronized Hashtable is fine in their case because they do the lock on write (which is all the Synchronized wrapper does anyway). Locks on simple reads through the indexer are not necessary with a Hashtable – only on enumeration.

On top of all this, the response from the Patterns and Practices team was really good. I think I got about four phone calls and twenty or so emails from Microsoft people in response to my feedback. And the dev lead himself walked through the code, took the time to verify that the problem I thought I saw wasn’t there, and let me know…over the weekend. Kudos!

Now I just have to figure out if it’s worth it for me to go in and change my code around to use the Configuration Management Application Block again. I wrote my own version that I’m employing, and of course it’s slightly different, and tailored specifically to my view of the configuration management problem. Microsoft’s stuff is obviously superior in many respects, as it has been more carefully architected and more thoroughly tested…and they’ve clearly got a great team backing it up. The only thing stopping me from leveraging their stuff is that what I’ve got now works. I think. :)

No comments:

Post a Comment