Rants

You are currently browsing the archive for the Rants category.

So you followed all my tips in the first installment, but you’re still worried that your code might be maintainable? Here are some more:

  1. Forced to fix a bug? Don’t worry, you can reintroduce it a couple of releases later, as long as you remembered not to add a regression test for it.
  2. If you must document code, don’t take the opportunity to explain WHY it’s doing what it’s doing. Just describe the obvious. Learn from the masters at Microsoft:
    // Initialize the column to '0'
    ColumnToSort = 0;
    // Initialize the sort order to 'none'
    OrderOfSort = SortOrder.None;

    No, really, that’s not made up – see for yourself.

  3. If you have to generate a lengthy SQL statement, avoid any kind of formatting of the code that might make it readable. Instead, cram it all on one line such that you can only see a small part of it at once.
  4. Avoid unnecessary timezone calculations by living on the Greenwich Meridian and only testing your code when DST is not in effect. Or preferably not at all.
  5. Threading is your friend. Find obscure ways to make sure your functions are not re-entrant. When reports of random failures come in from production environments, simply say you can’t reproduce them.
  6. Carefully read any coding standards that apply to your project and commit them to memory – otherwise there is a risk you might comply with part of them by mistake.
  7. A multidimensional array is a fine construct for storing your tabular data, but only if you refer to all your columns by numbers and don’t document them. Better still though, is a comma-separated list of pipe-delimited strings. For bonus points, use a delimiter that only rarely occurs in the actual data.
  8. Use floating point numbers for your currency calculations.
  9. Although cluttering up the code is normally a worthy cause, don’t waste your time validating user input. Rely on bug reports to find out the interesting effects of the ‘unexpected’ things they entered.
  10. Refactor. Because you feel like it.

Spot The Odd One Out

What’s the difference between these?

Deathstar

A sorry and tedious tale of hardware failures in a world where technology and frozen peas collide.

I got up this morning (or rather I was dragged up by Mia, as usual, at an ungodly hour) and the first thing I noticed as I wandered past my office on the way to the bathroom was a horrible silence where the happy whirring and grinding of a dust-filled fans and creaky old hard drives should have been.

Read the rest of this entry »

I guess you’re worried that when your project has no bugs, or when maintenance becomes too easy, someone is going to start wondering what they’re paying you for. What you need is technical debt. Here my top 10 ways to sneak some into your codebase. As well as plenty of future bugs, this will ensure that any maintenance or expansion tasks take as long as possible.

  1. Create lots of overloaded versions of the same function. Only use one.
  2. Copy and paste code. For bonus points, change the pasted versions slightly.
  3. Leave chunks of commented out code (“Green Code”) lying around.
  4. Don’t use existing core logic. Reimplement it within the user interface using your own strange methodology. Make sure it behaves subtly differently. No need to check that, it will.
  5. Check several unrelated changes in at once. Only mention one in the check-in comment.
  6. Never use 5 lines of code where 50 will do.
  7. Never use 50 lines of code where several classes that almost resemble a GOF pattern you misunderstood will do.
  8. Invent your own naming conventions.
  9. Never fix a bug – hide it. For example, deal with null reference problems by simply sticking an if-not-null around the offending code. This saves you having to look for the real source of the problem, and also ensures the bug will come round again in a more subtle and interesting manner.
  10. Leaving out documentation is too obvious. Much better to document it, but make sure the code doesn’t do what the documentation claims.

Don’t Do This

It should be basic common sense, but this issue is coming up again and again. Service X asks for your login details for service Y. Two things:

  • Don’t provide them
  • Walk away from service X

Read the rest of this entry »

Several hundred times today, you’ve asked me if I want to restart my computer to complete the installation of your security updates. Each time, the answer has been no. I’m sitting behind a firewall, and I wouldn’t dream of using your poxy web-browser. I’ll reboot when I’m good and ready. Thanks for listening.

Newer entries »