Octavia inherited a decade old pile of C#, and the code quality was pretty much what one would expect from a decade old pile that hadn't seen any real refactoring: nothing but spaghetti. Worse, it also had an "inner platform" problem, as everything they put in their API could conceivably be called by their customers' own "customizations".

One small block caught her eye, as suspicious:

public void SomeFunctionality { // Other functionality here int x = SomeIntMethod(); String y = PrependZeros(x.ToString()); // Do other things with y here }

That call to PrependZeros looked… suspicious. For starters, how many zeroes? It clearly was meant to padd to a certain length, but what?

public String PrependZeros(string n) { if (n.Length == 1) { return "00" + n; } else if (n.Length == 2) { return "0" + n; } else { return n; } }

We've reimplemented one of the built-in formatting methods, badly, which isn't particularly unusual to see. This method clearly doesn't care if it gets a number that's greater than 3 digits, which maybe that's the correct behavior? Inside the codebase, this would be trivial for Octavia to remove, as its only invoked that one time.

Except she can't do that. Because the original developer placed the code in the namespace accessible to customer customizations. Which means some unknown number of customers might have baked this method into their own code. Octavia can't rename it, can't remove it, and there's no real point in re-implementing it. Maybe someday, they'll ship a new version and release some breaking changes, but for now, PrependZeros must live on, just in case a customer is using it.

Every change breaks somebody's workflow.

[Advertisement] ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.