For about the 10,000th time today, I opened a file that looks something like this:
static Crypto()
{
// Set up the Rsa provider to use the machine key store. If you don't,
// creating the provider will fail when you run under ASP.NET.
CspParameters cp = new CspParameters();
cp.Flags = CspProviderFlags.UseMachineKeyStore;
// TODO: verify that we can encrypt 5 bytes, just so we don't get a
// false positive that makes us think we failed because of block size
I highly doubt that the developer who wrote it would have put up with this randomly indented presentation, so why do I have to? The problem is that developers love to hit the tab key to line things up, which generally inserts a tab character. Of course, different people and different editors choose different widths to use to display a tab character. Worse, it's easy to mix using tabs and spaces to align your code. After all, it'll look lined up to you, but when I open it, I get the mess above.
So, run, don't walk, to your favorite development tool and set the equivalent of this VS.NET option:

This will cause VS.NET to insert n spaces (instead of a tab character) whenever you hit the tab key, where n is whatever value you put in the “Tab size” textbox. I don't particularly care what number you use (although 2 is clearly the choice of the most discerning developers) - the point is that as long as you don't use tabs to line up your code, it'll line up for both of us.
This has been a public service message brought to you by the Terminally Picky Developers Association for Readable Code.
Posted
Dec 08 2004, 12:01 PM
by
craig-andera