Code, rants and ramblings of a programmer.
Browse by Tags
Tagged Content List
The File System is unpredictable
One of the more frequent questions I answer on StackOverflow is a variation of the following. I’m doing XXX with a file, how can I know if the file exists? The variations include verify no one else has the file open, if the file is in use, the file is not writable, etc …. The answer to all...
10 Dec 2009
Understanding the is, was and will of programming
When using an API you must take care to understand not only what it returns, but also for how long the data returned will be valid. This is very important to consider because programs must make either be making decisions on valid and predictable data or have appropriate fallback mechanisms for...
27 Apr 2009
Is it Serializable?
I’ve recently run across several APIs that have a dependency on only dealing with objects that are serializable (in the binary sense). Unfortunately determining if an object is serializable is a non-trivial task and rife with problems. These problems have a direct impact on the types of guarantees...
31 Mar 2009
Building a WeakReference Hashtable
Recently I ran into a situation on a personal project where I needed a hashtable like structure for a set of WeakReference values. When poking around for an existing implementation I saw found several versions which were very thin, type safe wrapper around a Dictionary<TKey,WeakReference>...
3 Mar 2009
A more usable API for a mutable thread safe collection
In my last post we discussed the problems with designing a safer API for mutable thread safe collections that employ only an internal locking system. The result was an API that was more difficult to mess up, yet pretty much unusable. Lets take a look at this problem and see if we can come up with a usable...
16 Feb 2009
Why are thread safe collections so hard?
Writing a collection which is mutable, thread safe and usable is an extremely difficult process. At least that’s what you’ve likely been told all through your schooling. But then you get out on the web and see a multitude of thread safe lists, maps and queues. If it’s so hard, why are there so many examples...
11 Feb 2009
NotImplementedException vs. NotSupportedException
In responding to a recent blog post , one of the readers, Jeremy Gray, noted that I was using a NotImplementedException where I should have been using a NotSupportedException . At first I did not agree. There was a method on an interface which my underlying object could not implement therefore...
12 Dec 2008
Immutable Collections and Compatibility with Existing Frameworks
When developing my immutable collections library , I spent a lot of time on usability. After all, if a library is not useful then what’s the point? A big portion of usability is being able to work with existing frameworks and technologies. For .Net and collections that means items like Data binding...
10 Dec 2008
Custom Exceptions: When should you create them?
I think the best answer is: rarely. It's really hard to go straight to a justification here though. I find that answering a different question will eventually shed led on when to create a new exception. "What are the benefits of creating a new/custom exception?" The answers...
20 Oct 2008
Immutability and ReadOnlyCollection<T>
I am a huge fan of read only/immutable collections and data. Hopefully the increased exposure through the blogosphere alerted users to the advantages of this type of programming for the appropriate scenarios. I wanted to discuss ReadOnlyCollection<T> in case devs looking around in the BCL discover...
22 Apr 2008
Design Guidelines: Provide type inference friendly Create function for generic objects
Really this guideline is a bit longer but putting it all in a blog title seemed a bit too much. The full guideline should read: "If a generic class constructor arguments contain types of all generic parameters, provide a static method named Create on a static class of the same class name as...
11 Apr 2008
Reference values in C++
Reference values are a powerful feature of C++ but I find they have one significant detractor. A developer can not look at an API call and determine if a parameter is being passed by reference or value (VB has the same problem). IMHO this is one item that C# got 100% correct. In C# developers must say...
3 Apr 2008
API Problems: CComObject::CreateInstance
CComObject::CreateInstance is a light weight method for creating instances of COM objects in your code. Unfortunately the design of the API makes it easy to introduce subtle errors into your code. The two problems are it encourages manually ref counting and the object initially has a ref count of 0....
28 Mar 2008
Page 1 of 1 (13 items)
© 2013 Microsoft Corporation.
Privacy & Cookies