Naming Conventions
Variable Named 'x' Causes Three-Day Debugging Session; Developer Claims 'It Made Sense at the Time'

Dear Marilyn: I named my variable 'temp' because it's temporary. Now I have 47 variables named 'temp' and I can't tell them apart. Help.
— Temporarily Confused in Tampa
Dear Temporarily: You have discovered, through painful experience, the First Law of Naming: A name should describe what something IS, not what it ISN'T. "Temporary" describes what it isn't (permanent). What IS it? A customer? An order? A database connection? Name it that.
The C# Naming Conventions
| Element | Convention | Example |
|---|---|---|
| Classes | PascalCase | CustomerService |
| Interfaces | IPascalCase | IOrderRepository |
| Methods | PascalCase | CalculateTotal() |
| Properties | PascalCase | FirstName |
| Local Variables | camelCase | orderTotal |
| Private Fields | _camelCase | _customerRepository |
| Constants | PascalCase | MaxRetryCount |
| Parameters | camelCase | customerId |
Names to Avoid
Never Use:
temp,tmp,datax,y,z(except in math)foo,bar,bazthing,stuff,itemmyVariable,theObject
Instead Use:
pendingOrder,cachedResultxCoordinate,yPositiontestCustomer,mockRepositoryorderLineItem,configurationSettingcurrentUser,selectedProduct
Quick Check
What is the correct naming convention for a private field in C#?