Freethought & Rationalism ArchiveThe archives are read only. |
07-16-2003, 06:13 PM | #131 |
Guest
Posts: n/a
|
|
07-16-2003, 06:16 PM | #132 | ||||||||
Veteran Member
Join Date: Jan 2001
Location: USA
Posts: 1,072
|
DNAunion: Ran across something interesting while reading today.
Quote:
Are these guys novices? No. Richard Waymire is an MCDBA, MCSE, MCSD, and MCT, and is Group Program Manager at Microsoft; and Rick Sawtell is an MCSD and MCT. Are they the only people who make errors or oversights in computer publications? Nope. Here are some Visual Basic .NET "goofs" from a Microsoft-exam-prep text by Microsoft Press. Quote:
Quote:
Quote:
Quote:
********************** DNAunion: And there are others, but I can’t remember where to find them off the top of my head. But here’s a sort of mistake that came to mind. Quote:
Quote:
Quote:
|
||||||||
07-16-2003, 06:42 PM | #133 | |
Veteran Member
Join Date: Jan 2001
Location: USA
Posts: 1,072
|
Re: Out of Curiosity
Quote:
One of the first things to do when verifying the validity of an application is to implement unit testing. That is where you test each individual function to make sure it produces correct results. In unit testing you start by feeding in values such that every possible program-flow pathway through the function is executed, testing the results to make sure they are correct. For example, if the function requires two Boolean data types as parameters, you have to feed it four test cases (true, true; true, false; false, true; and false, false). For other parameter types, such as numbers, you can’t try every possible combination (imagine a function that accepts 4 integers: you’d have to try about 4 billion to the 4th power test cases). In such circumstances you determine what that allowable boundaries are and test near them. For example, if the function takes an integer and it represents someone’s age, you determine that the range of valid values is 0 to 125 (or what have you). You then test these boundary values to make sure the program works. You then also test to both sides of each value, such as -1 and 1, and 124 and 126 (this helps catch the dreaded “off by one” errors). Values outside the allowable range should throw an exception or otherwise indicate failure. You should also test values much larger and much smaller (-1000 and +5000, for example) and also some near the middle of the allowable range. Thus you can limit your test to a handful (perhaps 20) test cases instead of billions, and, by “induction”, conclude that it works properly. There’s more to testing a program than that. But the idea of unit testing is, if all of the individual building blocks work properly, then the fully assembled program should too (but the whole is still tested several different ways anyway, just to be sure). One problem could be the overall design is flawed. Each unit could function properly but if the specifications they were built from are flawed then the overall system won't work. So before coding begins, the information system model must be reviewed by a team and given the thumbs up. Another process that would help spot errors is code reviews (going back to indiviual code units, not the whole shebang). For example, if programmer "Z" writes code it doesn't go into a production environment (i.e., it continues to work only with local copies of important information, which are located in a test environment) unti others have reviewed it and given it the thumbs up. Still there's more, but that should give an idea. PS: Of course, just as formal methods of writing are not usually used when posting at a web discussion forum, neither are formal program-testing procedures. |
|
07-16-2003, 06:54 PM | #134 | ||
Veteran Member
Join Date: Jan 2001
Location: Median strip of DC beltway
Posts: 1,888
|
Quote:
Quote:
|
||
07-16-2003, 10:05 PM | #135 | |
Guest
Posts: n/a
|
Quote:
His first and second laws are helpful though. I don't know how many times I've compiled something and find that I left out a } or got confused when adding something. The writer is a teacher at my college, although I've never taken one of his classes (PERL mostly). I've found I'm less error prone if I mark out the boundaries before actually coding. |
|
07-17-2003, 05:37 AM | #136 | ||
Veteran Member
Join Date: Jan 2001
Location: USA
Posts: 1,072
|
DNAunion: Just picked up another computer programming book and didn't read more than 2 pages before coming across an error.
Quote:
Quote:
|
||
07-17-2003, 05:47 AM | #137 |
Veteran Member
Join Date: Jan 2001
Location: USA
Posts: 1,072
|
DNAunion: Personally, I like Platt's laws of programming.
Platt's First Law: Every software project will take three times as long as your best estimate, even if you apply this law to it. Platt's Second Law: The total amount of crap in the universe is conserved. If someone has less crap to do it is because he has managed to push it off onto someone else: there is no such thing as making it disappear. PS: The first one I think is word for word...the second is a paraphrase. |
07-17-2003, 07:50 AM | #138 | |
Veteran Member
Join Date: Jan 2001
Location: Median strip of DC beltway
Posts: 1,888
|
Quote:
|
|
07-17-2003, 07:55 AM | #139 | |
Veteran Member
Join Date: Jan 2001
Location: Median strip of DC beltway
Posts: 1,888
|
Quote:
I don't see the bug... I cut and paste it directly, adding just enough to populate the list with 1,2, and 3 and a cout in the for loop. It compiles and runs with no problems. The only mistake that I can see is that he didn't initialize iter upon declaration. |
|
07-17-2003, 10:45 AM | #140 | |
Veteran Member
Join Date: Jan 2001
Location: USA
Posts: 1,072
|
Quote:
The error is that the code uses theList but the subsequent discussion about that code mistakenly refers to it as iList. That error is similar to one I made earlier and was "called on" (my logic was sound, but I accidentally used the wrong name). |
|
Thread Tools | Search this Thread |
|