However, I am a big fan of using the xml documentation facilities of Visual Studio to document the public interfaces of libraries.
Job security.
Yea but misleading comments are soooo much better.
Yea but misleading comments are soooo much better.
My favorite are the guys who think they're smarter if they keep variable names under 4 letters, don't use ANY comments (and due to the short variable names, the code isn't even slightly self-documenting), and love putting as many statements on one line as possible (C).
My favorite are the guys who think they're smarter if they keep variable names under 4 letters, don't use ANY comments (and due to the short variable names, the code isn't even slightly self-documenting), and love putting as many statements on one line as possible (C).
Yeah I was going to suggest short or misleading variable names as a form of job security. We all know how important it is to save space in those source files!
You mean statements that look something like this
int c = getD(foo);
int d = c ? foo : foo ? a : b;
I had someone once try to convince me that ?: operators were faster than if statements...
dspmkr(n+3);
gf3gd.npars += 3;
gf3gd.areas[gf3gd.npks] = 0.f;
gf3gd.dareas[gf3gd.npks] = 0.f;
gf3gd.cents[gf3gd.npks] = gf3gd.ppos[gf3gd.npks];
gf3gd.dcents[gf3gd.npks] = 0.f;
gf3gd.npks++;
for (i = gf3gd.npars - 3; i < gf3gd.npars; ++i) {
gf3gd.errs[i] = 0.f;
gf3gd.freepars[i] = 1;
}
gf3gd.freepars[gf3gd.npars - 2] = gf3gd.infixw;
gf3gd.nfp = gf3gd.nfp + 1 - gf3gd.infixw;
ilo = gf3gd.mch[0] + 1;
ihi = gf3gd.mch[1] + 1;
x0 = (float) ((ihi + ilo) / 2);
gf3gd.pars[gf3gd.npars - 3] = gf3gd.ppos[gf3gd.npks - 1];
gf3gd.pars[gf3gd.npars - 2] = sqrt(gf3gd.swpars[0] +
gf3gd.swpars[1] * gf3gd.ppos[gf3gd.npks - 1] +
gf3gd.swpars[2] * gf3gd.ppos[gf3gd.npks - 1] *
gf3gd.ppos[gf3gd.npks - 1]);
yucky! the sporadic indentation is the devil.
I can't count the number of times bad indentation has lead people to think their code is doing something it isn't. IE
Code:if(imcool()) prepareTheWorld(); sayImCool();
I dont want to asking homework questions on here but i am stumped.
I dont see any pro's to NOT document source code. Any help would be appreciated.
I can beat all that stuff, though I can't post a snippet. Worked a few years back trying to debug some issues in a very old point-of-sale system written in C. The modules were all numbered and named according to number, i.e. "MODULE_0323.C". Within each module the functions were assigned another number, and named as "0323_001()", etc. Global variables were treated similarly. Local variables were usually 1 to 5 characters with random underscores. The whole thing was intended to be supported by accompanying documents that they had stopped updating when Reagan was president. It was all very weird and surreal. I felt like I had stumbled through a mud brick wall into a dim, candle-lit cellar where monks copied ancient manuscripts.
You see, if your code can be followed by others, it means that your job can easily be outsourced. With undocumented (or carefully crafted misleading documentation) spaghetti code, they might try to outsource you, but in less than a month, they will call you and offer you your old job back with a raise.
If only that were true. Most places are too dumb to realize they need you. From my experience, they'll pay someone or a consultant 5x the money to figure out something you left behind taking 10x the time you could've done it yourself. Then they will pat themselves on the back.
The only legitimate reason I can think of not documenting your code is for security purposes. But even then, encryption is the answer, not obscurity.
Hmm, sounds like a trick question, but I'll bite. Over-commenting code can break up the structure and make it difficult to read, and many comments are too granular and don't add a lot of value. In my opinion code should be largely self-documenting, and where simply understanding the structure is not enough added comments should explain processes at a business level of abstraction. However, I am a big fan of using the xml documentation facilities of Visual Studio to document the public interfaces of libraries.