- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Respect to this post :)
This WTF is indeed a 2-in-1 and a prime example of how not to code present and past. Never in a million years is it okay to use cOut as a variable name, and all those #defines to cater for the possibility of typos...
It is people like this that give software engineers a bad name. Throw them out, they are imposters!
Admin
This is why code should be case insensitive. Who would create a variable called cOut?
Admin
You laugh, but I've long thought that it would be really cool if compilers came with a spell checker for sort of that purpose. I wouldn't have them correct things for you, but it could at least say "'mlaloc' undefined: did you mean malloc?" in the error message.
If it were really slick, it could be interactive and ask you if you wanted to correct the source.
(Same deal with at least some other syntax issues.)
Admin
I'm not sure this WTF can be cited as a reason for anything, except perhaps the introduction of the death penalty for pre-processor abuse.
On the other hand, I am no great fan of case-sensitivity in code. It is immoral to distinguish between two identifiers solely by case, since screen reading software can't distinguish between them and so the practice makes life difficult for programmers with impaired vision. It some jurisdictions, it might be construed as a gratuitous barrier to employment, which raises the pleasant possibility of the original author of this WTF spending time in jail for their sINs.
Admin
This is the funniest WTF I've seen in ages!
[sarcasm] Of all those time I accidentally typed 'retrun' or 'flase' or 'ture' 'viod' or ... Why did not think of that! [/sarcasm]
Admin
due to european education, I often type
ovid // instead of void
Admin
Actually, Visual Studio 2005 does offer something like that, at least in the VB editor. It actually catches those mistakes (use of a superfluous letter, inversion of two letters and so on) and proposes a correction to the closest correct symbol. It does not work on keywords though, only on types/variables.
Admin
In the source base I work on for my day job (a 10+ year old C/C++ application), I once found an interesting alternative to using a union. It went something like this (apologies for any syntax errors - this is pseudo-code):
typedef struct { ... int someVariableName; ... } WHATEVER;
#define AnotherVariableName someVariableName
(needless to say, I killed it)
Admin
Smalltalk IDEs will do this for variables, classes, and message sends; Squeak at least will give a list of the closest matching symbols and offer to declare the variable, create the class, ignore, etc.
Admin
void Serialize(ostream& cOut, vector<CRcpt>& rRcpt) { ... }
except that redefining begin and end will break that, of course. (It will break #include <vector> in fact, as well as <string> etc).
The programmer is not all innocent though.
Not const-correct. You don't modify the vector when you output it. And should use std::ostream & and std::vector, not "using namespace std". Finally style issues: function names should begin with lower-case letters and classes should not be given a C prefix so class Rcpt not CRcpt.