Monday, November 14, 2005

This sucks

When it comes to wars about programming style, I try and stay neutral. The one glaring exception to my neutrality is the "this." prefix for unambiguous field accesses. It drives me absolutely crazy. I don't understand why the style has prevailed in both the Java and the C# communities. Prefixing an unambiguous field with 'this.' is verbose and syntactically meaningless. At least when you use a convention like "m_", "i_", or simply "_" to prefix a field you are adding something that has meaning to the compiler.

When I first started using Eclipse I was very happy that their code generation rules allowed me to specify a prefix for fields. I counted it as a small victory, that there were other like minded people in the world that didn't think "this." was the stylistic answer for differentiating automatics from members. Unfortunately, while reviewing the new features in Eclipse 3.2 M3, I see they've added a new "Clean Up" rule that will add a "this." qualifier to unqualified field access. Dammit! I guess I must chock one up for the opposition.

One final point, please don't tell me about conversion and interoperability across languages being a valid reason to use "this." instead of a prefix. I don't carry a canoe around just so someday I can cross a river, so don't expect me to burden my code either.

Post a Comment
The Out Campaign: Scarlet Letter of Atheism