Last time, we implemented a MyCommands class to keep track of commands invoked by the MyCommandsController. Here is the MyCommands as we left it: What possible issues do we have here? The first one that comes to mind is the…
Find the issue: long requests
In the previous post, I discussed a few design changes to a sample Web API controller to fix up the parameters. Here is where we ended up: Of course, we’re not done yet. I ask again: can you find the…
Find the issue: parameter types
Can you find the issue in this ASP.NET Web API code snippet? I admit that this is sort of a trick question because there is certainly more than one issue. But let’s start today with the Post() method signature. Judging…
The right tool for the job
In my earlier days of designing and coding .NET projects, I would strive to build pure C# implementations, no matter the scenario. For example, if my .NET app needed to capture and log standard output from an external process, I…
Exact square roots (continued)
Last week, I introduced a data structure kata involving exact square roots. At the time of that writing, I had implemented a RootTerm struct which could represent real and imaginary square roots. Today we’ll pick up where we left off…
Data structure kata: exact square roots
Many programming courses introduce the concept of data structures with complex numbers as a motivating
The binary coverage hypothesis
Everyone loves to hate code coverage. But I have started to notice one interesting consequence of using coverage metrics that I refer to as the binary coverage hypothesis: A class should either have full unit test coverage or none at…
Interface anti-patterns: overload overload
Continuing on the theme of interface anti-patterns, let’s talk about overloaded methods. Specifically, let’s talk about overloaded method overload. You’ve probably seen it before. You need to implement an interface and find that there are multiple overloads of each method.…
Interface initialization anti-patterns
It’s a pain that you cannot define constructors for interfaces, isn’t it? To be honest, I’m not so sure… The perceived need for a constructor — typically realized as an Init()-style method — is often a sign of a design…
Nothing beats the real thing
One common pitfall when operating in a mock-heavy TDD context is the tautological test. This is especially true for code which involves awkward dependencies. “I want to avoid talking to the real [database|API endpoint|etc.] here in this class,” you say.…