Four Irritating Lines of Code
June 25th, 2005

At many places in the framework, you’ll see properties of types named for the enumerations or types they receive. I was indifferent to that until just now.

I just wrote these four lines of code. It took much longer than it needed to.

BinaryFormatter f = new BinaryFormatter();
f.FilterLevel = TypeFilterLevel.Low;
f.TypeFormat = FormatterTypeStyle.TypesWhenNeeded;
f.AssemblyFormat = FormatterAssemblyStyle.Simple;

Consider the last three lines. None of the enumeration names are even close to the corresponding property on the formatter.

For all three of these, I typed out something like this:

f.FilterLevel = FilterLevel.

[No Intellisense, there’s a problem]

[Backspace repeatedly]

f.

[Intellisense shows up; oh, it’s “TypeFilterLevel”]

f.FilterLevel = TypeFilterLevel.Low;

Maybe the usability studies didn’t make it to System.Runtime.