Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
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



List of 57 messages in thread
TopicAuthorDate
defensive coding how and why            01/01/70 00:00      
   What do you mean?            01/01/70 00:00      
      Elegant            01/01/70 00:00      
         Paradox?            01/01/70 00:00      
      clarification            01/01/70 00:00      
         Remember            01/01/70 00:00      
            Absolutely, and even then should be avoi            01/01/70 00:00      
            Absolutely, and even then should be avoi            01/01/70 00:00      
            extrodiaray?            01/01/70 00:00      
                extrodiaray?            01/01/70 00:00      
                  Goooooogle            01/01/70 00:00      
                     No, he does not            01/01/70 00:00      
                        proofreading            01/01/70 00:00      
                     Another challeneg            01/01/70 00:00      
                        another challenge            01/01/70 00:00      
               OK, I can not Spell            01/01/70 00:00      
                  this is my point            01/01/70 00:00      
                     I sure you could, But            01/01/70 00:00      
                        Really?            01/01/70 00:00      
                           professors and classes            01/01/70 00:00      
                           Really !            01/01/70 00:00      
                              Hmmm            01/01/70 00:00      
            defensive commenting            01/01/70 00:00      
         Don't know            01/01/70 00:00      
            Ok, let me get away from that word            01/01/70 00:00      
               Gotcha            01/01/70 00:00      
                  and I came to truly despise that word wh            01/01/70 00:00      
                     Just like driving            01/01/70 00:00      
            Elegant equals...            01/01/70 00:00      
               that it            01/01/70 00:00      
               Oh, how true...!            01/01/70 00:00      
                  It's never the author's problem            01/01/70 00:00      
                     I knew a person who told me about a real            01/01/70 00:00      
                        A blissful existence            01/01/70 00:00      
                  Your bugs versus my bugs (or vice versa)            01/01/70 00:00      
                     common wisdom has it that the average pr            01/01/70 00:00      
   One exception            01/01/70 00:00      
      exceptions            01/01/70 00:00      
         vice versa            01/01/70 00:00      
            what is obvious            01/01/70 00:00      
               your mileage may vary            01/01/70 00:00      
                  that is the very same            01/01/70 00:00      
                     competent            01/01/70 00:00      
                        please define "working"            01/01/70 00:00      
                           competent programming => working program            01/01/70 00:00      
   i'm new            01/01/70 00:00      
      if you move your eyeballs a bit to the l            01/01/70 00:00      
         Coding Bible            01/01/70 00:00      
            Precedence vs. explicitness            01/01/70 00:00      
   Outlaw coding!            01/01/70 00:00      
      a program it is, by definition, asynchro            01/01/70 00:00      
         Methinks the point was missed            01/01/70 00:00      
            "Easy?"            01/01/70 00:00      
            but we agree            01/01/70 00:00      
      VIPER?            01/01/70 00:00      
      What does "timing" mean?            01/01/70 00:00      
         excuse the foreigner, if he was not clea            01/01/70 00:00      

Back to Subject List