??? 08/16/05 09:59 Read: times |
#99500 - defensive commenting Responding to: ???'s previous message |
<joke>So if we speak of defensive programming, we could have defensive comments, too. Like: ;***************************************************************** ;I was forced to write this by my boss, but I don't like it, ; so if there are errors, it's because I really didn't know ; how to refuse... ;*****************************************************************</joke> But it comes from a real story: When I learned programming at school (at the age of 16 - we were doing a pascalish style but in our language, then hand-translating it into BASIC, as that was the only available language on PMD-85, our local school computer), we got once the task to find solution of the quadratic equation. The general idea is to check if b^2-4ac is negative and if so, print some warning message (we were not supposed to deal with complex numbers at that time) and end. One colleague of mine wrote something like the following: 10 PRINT "IF IT WRITES 'ERROR ON LINE 40' THE EQUATION HAS NO SOLUTION" 20 INPUT "ENTER COEFFICIENTS A, B, C", A, B, C 30 R=B*B-4*A*C 40 X1=(-B+SQR(R))/2/A 50 X2=(-B-SQR(R))/2/A 60 PRINT "X1="; X1; "X2="; X2 70 END Jan Waclawek |