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