stephenbrooks.orghiddenTemporary Bilge

bad_programming_addendum.txt

There are rather more I can think of (mainly because I've done some of
them):

- [me] Use characters outside the standard ASCII set like degree or square
(superscript 2)

- [Something I've seen others do] don't use the memory manager when you can
just make a fixed array with 10000*10000 entries, that should be big enough
for anything!

- [me] Handle exceptions like this

if (11==sscanf(str," %d %d %g %g %g %g %g %g %g %g %g",
&pn,&pid,&ke,&wt,&x,&y,&z,&vx,&vy,&vz,&t))
{
...
}
else {printf("Error bad mallards\n"); getchar();}

- [me] Make comments only decipherable if you know specific people by name,
e.g.

for (sign=0;sign<2;sign++) for (useful=0;useful<2;useful++) for
(i=0;i<=20;i++)
{ // Double-binned stuff that Roger was going on about
for (j=0;j<=20;j++) pizp[sign][useful][i][j]=0;
for (j=0;j<36;j++) pizth[sign][useful][i][j]=0;
}

- [me] Use the conditional ternary operator on Lvalues, e.g.

*(sign?&gminus:&gplus)+=gwt; *(sign?&gminusvar:&gplusvar)+=gwt*gwt;

- [others] Limit all function names to 6 characters or less, in all-caps. 
Then make a handy paper index where you can look up what PR09CF does

- [me, now corrected] Make variable assignments inside short-circuited logic
statements, so you don't know whether they have been initialised or not

float x,y;
if (fabs(x=ax-bx)<50 && fabs(y=ay-by)<50) {...}
// Now try to use y!

- Make a global but then pass it as an argument to a function *anyway*

- Write code that relies on the fact "int a,b;" puts a and b in adjacent
memory slots, e.g. memset(&a,0x00,8);

- [me] Create a really long structure containing multiple types and then
initialise it all in-line, e.g.

} ops={"config.txt", 0,180,-1, 0, 1,0, COMMANDLINE, -1, 0, 1,100,
"auto.sav", 0,0,0,0, 0,
"results.dat","results.txt", {3,6,1,"Mpts"}, {"queue.txt",NULL,0,0,5,0},
100000,50,10000,10,
1,24,12,NULL,'L', 0,0,0,0,0, NULL,-1, "ftp -s:script.ftp",0,0,
NULL,"Unknown","",
NULL,0, 0, "none", 0,100, NORMAL_PRIORITY_CLASS,THREAD_PRIORITY_NORMAL,
50<<20,0.5,NULL,'B'};

Very readable!

- On Hungarian notation,
double *dwString;
: contact : - - -
E-mail: sbstrudel characterstephenbrooks.org
Yahoo: scrutney_mallard
Jabber: stephenbrooksstrudel characterjabber.org
Twitter: stephenjbrooks 9.86millionaccesses