Archive for September, 2015
I’ve recently noticed the emergence of a recurring pattern in my code. Each project has the same class in it, and this duplication has really been bothering me. The solution to this repetition just hit me this morning while I was reading Jon Skeet’s “C# In Depth.”
First, let me illustrate the pattern I was using and why it’s a problem.
I’ve been refactoring 1-tiered legacy code into something testable. This has involved creating a data layer class, typically called
DataProvider which implements an
IDataProvider interface so that I can easily mock out the data access. Now, because any kind of data access is extremely likely to have unmanaged resources,