Vulgare variable names

I've seen a bunch of inappropriate variable names online. I was told by a teacher to never be cute like that, and I follow his advise. I was able to find something I'm not quite sure about now :)

I have two words, which I've named:
1
2
string fWord;
string sWord;


Think fWord is going to be a problem? Is the industry so politically correct?
Last edited on
closed account (3hM2Nwbp)
The only thing that you have to consider when choosing a variable name is that it sufficiently self-documents itself. Follow that guideline and you:

A) Probably won't ever need to use "vulgar" terms unless you're writing a sexual reproduction library.

B) Probably won't get confused with your variable names so often.

C) Won't incur the wrath of others that depend on your code.
closed account (1yR4jE8b)
Teachers live in the mystical land of Academia, and the things they tell you pretty much never apply to the real world.

For example, I was reading the Doom source code and noticed a variable called "fuck". It's completely undocumented, and I have no idea what it does.

I've also seen a few gems in my time, like:

1
2
Exception up = new Exception("Something is really wrong.");
throw up;  //ha ha 




//
// Dear maintainer:
//
// Once you are done trying to 'optimize' this routine,
// and have realized what a terrible mistake that was,
// please increment the following counter as a warning
// to the next guy:
//
// total_hours_wasted_here = 42
//


// Magic. Do not touch.



#define TRUE FALSE //Happy debugging suckers


Ha the dear maintainer one was awesome.
closed account (o1vk4iN6)
1
2
Exception up = new Exception("Something is really wrong.");
throw up;  //ha ha  


Is the memory leak suppose to be part of the joke ?
@xerzi
Looks like C# or Java to me, so it won't leak memory.
Last edited on
Teachers live in the mystical land of Academia, and the things they tell you pretty much never apply to the real world.

I disagree.

Crude language is never appropriate in source code, except when in lists of specifically vulgar words. It isn't funny, or cute, or smart, and all it shows the reader is that the writer's head is not where it belongs.

Whom would you hire? Someone whose code looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
int bitcount( unsigned long x )
{
    int result = 0;
    while (x)
    {
        if (x & 1)
        {
            result += 1;
        }
        x >>= 1;
    }
    return result;
}

Or like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
int bitcount( unsigned long EXPLETIVE )
{
    int VULGARITY = 0;
    while (EXPLETIVE)
    {
        if (EXPLETIVE & 1)
        {
            VULGARITY += 1;
        }
        EXPLETIVE >>= 1;
    }
    return VULGARITY;
}

Crude words stand out just as much. What they show the reader are the following things:

1. The writer does not care about code maintainability.
2. The writer very likely does not understand his code very well.
3. The writer's code probably has some serious bugs.
4. The writer does not know how to properly name something.
5. The writer does not care about working with other people.
6. The writer is wasting time (thinking about stuff other than his program).

Just for starters. Your teacher is right about this.

BTW. "vulgar" means, in today's language, anything that is crude or offensive, not necessarily just sexual.

edited to fix speling missteak
Last edited on
Well, if the variable name is explicative, then that's alright. Expletive would be a different story, though.
maybe in the coorporate world but probrably not in the entertiainment/science world with games and such. It may be offensive if it was a slur but all i could see happening is a chuckle.
@helios
Holy crap! I can't believe I made that mistake! I'll fix it above.
closed account (1yR4jE8b)
Whom would you hire?


If the person who sometimes use expletives in his code writes code like John Carmack, you bet your ass I'm going to hire him. I'm in the business of shipping code that works, period. I could give 2 shits what his variables are called.
Last edited on
hurhurhur variaballs only write dirty code if your bored on your own and it turns you on
Topic archived. No new replies allowed.