Of Style and Substance

Published on

I had a spirited discussion today about the use of the keyword this in C#. I love conversations like that. Great things come from debates over the inane and trivial in programming, I've discovered. Some of the most impressive growth I've experienced as a software engineer has stemmed from debates and conversations about the nuances of programming languages, platforms, and computer science in general.

This particular conversation got me thinking about the style and substance of programming, especially where the two converge. We've all worked somewhere that has a set of coding practices and standards by which you should adhere. Sometimes we agree, sometimes we don't. But in the end, does it really matter how we format and structure our code at such a granular level?

I would say yes and no.

No, because two solutions that are functionally equivalent both get the job done. What is a coherent and obvious framework for one developer may or may not be coherent and obvious to another.

Yes in the sense that a standardized code base is easier to maintain and develop around. Yes in that there are sometimes good reasons to follow a given convention based on the project and the coding situation you find yourself in.

For example, in my discussion concerning the use of the keyword this , we were debating its use in instantiated classes. The opposing view was that this is unnecessary and that class level members should be prefixed for easy recognition within subsequent calls. This is a perfectly valid coding convention.

My view is that using the this keyword is a more clear demarcation of the scope of a class member or property and separates the member from those scoped to the current method or code block. This is also a perfectly valid coding convention.

So is there a right answer? Maybe, but probably not. One could possibly make an argument that one solution could be more easily understood or that one is harder to refactor, but such a case would be hard to make convincingly, I think. It would be especially hard to sway someone of the opposite persuasion.

But having your convention challenged is immensely helpful. It forces you to really think about why you do what you do. Debate forces you to defend your ideas. You're given an opportunity to both learn and to teach.

We can all learn from one another in the field of computer science. We ought to take and embrace the chance to debate with our colleagues. We can and should gather, as the ancient Greeks did in times past, to engage and strengthen our minds and those of our brothers.

Maybe leave the togas at home though.