In the process of researching about
IDisposable, I found a lot of illuminating discussions on Stack Overflow. It became apparent that there were a few regular players who had intelligent things to say on the topic, and I would follow their links and profiles to find more intelligent things they had to say on other topics.
One of these players is Daniel Eerwicker, who created a “General Theory Of Resources” in a blog post that I feel obligated to describe as epic. It piqued my interest, since this was exactly an area I had questions about. He describes the cultural problem with the IDisposable pattern:
But these mere technical problems are minor compared with the cultural problem that exists around this technique. These are caused by copious amounts of official or semi-official documentation which confuse it with finalizers, in apparent denial of their different areas of applicability.
I was confused by the documentation he is talking about:) At the end, he proposes his own alternative to Microsoft’s IDisposable pattern that he calls “Gateways.” It’s a long article, but very interesting.