Long Variable and Method Names in C#

Very often , when working with others code , I am confronted with the following :

DataTable dt_  = new DataTable();
int x;
int y;

AND

public List<int> ListItems()

In older languages , perhaps there was an argument to be made for short variables names.  Perhaps underscores were required.

But with the long hailed intellisense and similar features in most IDE’s , this horrendous  , lazy code maintenance nightmare should be stopped. There’s no excuse for it. Underscores are ultra-difficult and slow to type (try it – see how you have to think about where the underscore is before you hit it) and short variable names make code difficult to understand and follow.

This type of working is akin to using too many acronyms in a sentence an then expecting the person you are talking to to be able to follow what you are saying.

Can’t we all do something like this?

DataTable tableToHoldUserData = new DataTable();
int noOfArrayElements;
int UsageCount;

In a piece of code I was writing recently , I wrote this :

tightlyHeldMidCapsNoShares = DetermineNoOfSharesToUseInCategory(tightlyHeldMidCapsPercent, divider);

A bit long winded? Sure. Can you determine what it does? Probably. Even without knowledge of the stock market (which is what it related to).

Leave a Reply

Your email address will not be published. Required fields are marked *