This may sound like common sense, but do you know why?
Last week, I was watching a popular training video online regarding the repository pattern and data contexts. In the video, the author demonstrates a piece of code that exposes the data context in such a way that if his repository classes were used in some other application, a single instance of data context may end up being used in multiple using blocks.
So I wrote up an explanation of the oversight and sent it off to the author, Dan Wahlin. He told me that it was as designed and that the data context was to be "available even if it was previously disposed."
So shocked was I that I scoured the internet for an explanation as to why this is wrong, but I came up bust. In the end, I was able to convince him to change it, but it was an uphill battle. I find that this is the type of rubish code that readers see and unfortunately take as gospil.
But for many developers, dispose is somewhat of a magical device. It …