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
Microbenchmarks with BenchmarkDotNet
They say that the fastest prime number algorithm for small inputs (up to 216) is a lookup table. But this got me thinking — would it be faster to use HashSet.Contains or a List.BinarySearch? The answer to this type of…
Edge cases: overflow
Consider this (rather suboptimal) prime factorization algorithm: You can run it like so and see that it returns the proper factorization for a variety of Int32 values: In fact, it works properly for any possible Int32 — except one very…
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.…