If you can’t spell, step away from the database

Sometimes moronic looking code is actually really smart. I’m working with something that reads like this:



do
{
    // Can't really reveal too much :(
} while (0)


“Now why the hell would anyone do it that way?” I’m sure you’re asking. Thing is, it makes perfect sense, and nothing else works.

I have one -

There is no point in putting “TABLE” in the names of your tables. We already know it’s a table, you don’t have to call it “EMPLOYEE_TABLE”. It’s no fun banging out queries when you have to put _TABLE on the end of everything.

In the old version of Word that I had, the spellchecker thought that the word “address” was spelled “adress.” So I re-learned it with the wrong spelling. And then I had to re-re-learn it.

Welcome Halleluau. Like the name.

I find this to be tolerable. Redundant, yes, but tolerable. There is a school of thought where everthing includes its type in its name, for instance:

Dim strMyTextString as string
Dim intMyInteger as integer

Using your example, an Oracle query might read:

Select FIRST_NAME from EMPLOYEE_TABLE WHERE IS_ACTIVE = ‘1’

Yes, a little redundant but not unreadable.

Yes - it’s supposed to be helpful if you’re working with a lot of variables in a language that strongly enforces types - rather than compiling the thing and at some point realising that it isn’t quite working, you would notice that you’re writing an expression with incompatible types at design time.

I used to teach databases - this is making me cry!

Both of the guys in control of our web server are dyslexic. The main one seems to have it quite badly and won’t use any sort of coping strategy (according to the other). Plus he seems to never rename anything. He’s also contantly reorganising the server. So we’re constantly battling with misnamed files, his inability to accept the concept of case sensitivity, things getting deleted and so on.

The last time he deleted my directory it took him four attempts to spell my name correctly when he created a new one. Why on earth he can’t cut and paste from my emails, I don’t know. and more often than not if we point out he’s missspelt or buggered up the case of a directory he simply creates a new one and puts in a link between the two, which makes maintaining our pages much harder. We know what we think the directory should be called, but we have to guess how he may have spelt it and where on the server he may have put it (no one has yet been able to work out the logic behind his directory structure).

but we are talking about a database - there are only, what, three kinds of thing: tables, columns, and views. It just ain’t worth tacking _table onto the end of everything. And it’s not as if the columns all have _column on the end, although go knows there are probably some people who do that. It’s just syntactic clutter.

My precedessor at my current place of work had a first name that started with a “D”. I know of this because dozens of fields in each table that my precedessor had added bore field names that started with a “d” — dDue_Date, dBleed, dCompanyCode, etc.

Why in the world is he still allowed to work there?

Let me guess… a lot of “break” statements were involved?

None at all. This is a macro that needs to have extremely local scope for its variables, and just using braces would cause it to not compile in something like this:



if (...)
    MACRO(....);
else
    MACRO(....);


What really bugs me are flippant comments in code. I see them all the time, like

// this is really icky code but it works

or

// HACK: remove this – dfw 092501

(no one knows who dfw is, and he hasn’t worked for the company in 3 years)

or

/* shoot this code. now. */

Why bother to put something like that in there at all? Either don’t bother to make a comment, or actually do something about it! If you’re trying to be clever, that’s what e-mail is for!

What really bugs me is the most egregious offender in my company is my supervisor, who is enough a pedant to frequently criticize me for putting my brackets on the same line as an if statement.



if (youAreAPedanticJerk)
{
   your_hands.clap();
}


is acceptable practice, while



if (!it.broke()) {
   it.dontFix();
}


will bring about the downfall of humanity as we know it.

Your boss is a twat. It’s a complete waste of vertical space to devote an entire line to holding an open brace. I fucking hate that.

But I suppose that’s what they invented indent.

I agree with your boss on that one. Once you get to 10 nested levels or so, trying to read through code someone else wrote takes 3-4 times the time if, when the bracket levels don’t match up spatially. Particularly when dealing with long quotes that have to wrap around and screw up the indent pattern, so you have to scan for brackets to maintain flow.

SHUDDER!!!

If you have 10 levels of nesting, you should decompose that routine. I don’t think any bracketing style could make 10-level indentation readable.

Your boss is correct. You are living in the 80s.

I hope you realize you both have your preferences for the exact same reason: readability. His position is that when blocks begin and end on the same level, the code is more readable. Your position is that you can only fit 24 lines (79 characters wide) of code on the screen at a time, so wasted lines make it less readable.

I would advise you kick up your resolution, reduce your font size, hide some IDE features, or implement some combination of all 3 in an effort to overcome this irrational need to conserve the over-abundant screen real estate modern development environments provide.



me.bite();


Forgot this was the Pit, so I need to make it clear: I was kidding.

I don’t care one way or the other, and I think it’s a completely pedantic distinction that matters only to people who don’t have more important things to think about. It’s particularly annoying when the code in questioin was a simple 4-line if-else deal where the bracketing style had absolutely no bearing on the readability of the code as a whole.

It’s stuff like this that makes me realize more and more that I don’t want to be a programmer. I’m not anal-retentive enough to care, but I’m just anal-retentive enough that it bothers me when people point it out.