Comment "Code For The Next Guy" (Score 1, Informative) 662
I have been a programmer for more years than I care to think about. My motto for the longest time has been "Code For The Next Guy". Invariably, the code that you write today will likely be maintained or enhanced by someone OTHER THAN YOU tomorrow. So, when coding, keep that in mind.
Some guidelines...
- Whitespace is your friend. So is proper indentation of your code. Make your code easy on "The Next Guy" to READ.
- There are 100+ ways to code a solution to a problem. The issue is that about 99 of those ways suck. Don't reinvent the wheel. Like a previous poster stated, read code from other developers, follow a programming standard and stick to it.
- Document code that needs documenting. If you are implementing an algorithm to solve a problem that might not be clearly evident to "The Next Guy", document that. Do NOT bother documenting the obvious, such as "Increment Counter" when you are incrementing a counter variable. If "The Next Guy" doesn't understand that, there will be issues.
- Make your variable names meaningful. You can get away with single character variables in a "for" loop, but that's about it. In the same vein, however, don't be ridiculously verbose with your variable names. A variable named "companyName" is much better than "coNm" and even better than "cn". A variable named "nameOfTheCompany" is overkill. Your variable should clearly denote the contents that are being stored.
I could go on an on, but you get the point...
"Code For The Next Guy"...not for yourself.