In my list of unsavory exception practices, I mentioned logging overload as a common issue. It often arises in code like this: We can see that some of the individual actions have exception logging, but so does the entire outer…
The testable adapter anti-pattern
Let’s say you’re writing a module to deal with Windows optional features. Following the guidance of the Ports/Adapters/Simulators design approach, you come up with a port IFeatures and an adapter WindowsFeatures. “I must make my adapter testable!” you exclaim, and…
Find bugs for (almost) free
Want to find bugs in your code for (almost) free? Try static code analysis — a useful technique, though often maligned by developers for noise and “false positives”. If you need an appeal to authority to be convinced, see how…
EventSource and rich payload data
Long ago, I wrote about EventSource, the simple and modern ETW-based tracing solution for .NET 4.5+. Much to the diagnosticians’ delight, EventSource continues to evolve in .NET 4.6. Check out Vance Morrison’s post describing the useful new “rich payload data”…
The crumbling bridge to innovation
Technical debt is well-trodden ground in modern discussions of design and development. So-called “software rot” can damage team productivity and make every bug fix and feature addition all the more painful. Less often mentioned are the consequences of the same
Dictionary and memory usage
Consider this code using Dictionary<TKey, TValue>: One might assume that the capacity (actually bucket count in this case) and memory usage will stabilize after repeatedly filling then clearing the collection. Unfortunately, this is not the case. Here is the output…
Once is not enough
In the olden days of boxed software products, the “full test pass” was a borderline sacred ritual performed near the end of a release. Ostensibly, its purpose was to make sure all the product features worked as intended — for…
Oversubscribe now!
For small chunks of compute-bound work that must be offloaded to the background, you can choose from several APIs and patterns in .NET. In code written before .NET 4.0, you would probably use ThreadPool.QueueUserWorkItem. In modern day apps, you might…
Destroy all* test environments
Test environments are a liability. Sometimes they’re so good, they’re bad. Though most of the time they’re just bad. So what then, do we just test in production exclusively? Obviously it’s not that simple and there is a more nuanced…
Easier to test => better
Rick Mugridge presented a paper “Test Driven Development and the Scientific Method” at the 2003 Agile Development Conference. There he speaks of theory simplicity and draws a parallel between Occam’s razor and the (positive) pressure of TDD to “choose the…