Final Jihad: Coding Style
by Mark Storer · in Technical Issues · 05/16/2005 (10:38 pm) · 0 replies
Experienced programmers can usually agree on one thing: THEIR coding style is right, and everyone else's is wrong.
But there are some common things we can all (grudgingly) admit to:
1) Consistency is your friend. Stick to one style.
2) It's polite to use someone else's style when working on their code.
2.1) Many people aren't polite.
3) A coding style should discourage buggy code. If your coding style is "use single-letter variable names until you run out of alphabet", or "put as much stuff as possible on a single line", you might want to reconsider.
3.1) Many shortcuts like this are attempts to avoid typing. Learn to touch-type. It's Very Helpful, particularly if you want to do this sort of thing for a living. Being freed from Hunt-n-Peck-ville is liberating to say the least. Learning to type is DULL. But worth it.
4) Most of your code (once you've learned the language) is for your fellow human being's benefit (or your own in 6 months when you have to dig back into some utility class to fix a bug in a file you haven't so much as glanced at since you wrote it). A compiler doesn't care about variable names or white space. The rest of us do.
5) MINE IS RIGHT.
I've managed to survive several different styles (after much wailing and nashing of teeth). It's really not that big a deal, though it's entertaining to dive in and argue their relative merits. Having said that: Let the entertainment begin!
But there are some common things we can all (grudgingly) admit to:
1) Consistency is your friend. Stick to one style.
2) It's polite to use someone else's style when working on their code.
2.1) Many people aren't polite.
3) A coding style should discourage buggy code. If your coding style is "use single-letter variable names until you run out of alphabet", or "put as much stuff as possible on a single line", you might want to reconsider.
3.1) Many shortcuts like this are attempts to avoid typing. Learn to touch-type. It's Very Helpful, particularly if you want to do this sort of thing for a living. Being freed from Hunt-n-Peck-ville is liberating to say the least. Learning to type is DULL. But worth it.
4) Most of your code (once you've learned the language) is for your fellow human being's benefit (or your own in 6 months when you have to dig back into some utility class to fix a bug in a file you haven't so much as glanced at since you wrote it). A compiler doesn't care about variable names or white space. The rest of us do.
5) MINE IS RIGHT.
I've managed to survive several different styles (after much wailing and nashing of teeth). It's really not that big a deal, though it's entertaining to dive in and argue their relative merits. Having said that: Let the entertainment begin!
About the author