FRDB Archives

Freethought & Rationalism Archive

The archives are read only.


Go Back   FRDB Archives > Archives > IIDB ARCHIVE: 200X-2003, PD 2007 > IIDB Philosophical Forums (PRIOR TO JUN-2003)
Welcome, Peter Kirby.
You last visited: Today at 05:55 AM

 
 
Thread Tools Search this Thread
Old 07-16-2003, 06:13 PM   #131
HeatherD
Guest
 
Posts: n/a
Talking

Beanie's Laws
 
Old 07-16-2003, 06:16 PM   #132
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default

DNAunion: Ran across something interesting while reading today.

Quote:
"You can also rewrite it using ANSI SQL:

SELECT emp_id AS Employee_ID, lname AS LastName, fname AS FirstName
FROM employee

************************
Note:
The AS keyword isn't required. For example, the following statement returns the same information shown in the preceding query:

SELECT emp_id AS Employee_ID, lname AS LastName, fname AS FirstName
FROM employee
***********************"
(Richard Waymire & Rick Sawtell, Teach Yourself Microsoft SQL Server 2000 in 21 Days: Second Edition, Sams, 2003, p331)
DNAunion: They'd better return the same thing...they're identical! Hmmm, copy and paste gets even these authors!

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:
Code:
Private Sub mnuStop_Click(ByVal sender As System.Object, ByVal e _
        As System.EventArgs) Handles mnStop.Click
    myDoughnutMachine.Enabled = False
End Sub
(from Developing Windows-Based Applications with Microsoft Visual Basic .NET and Microsoft Visual C# .NET, Matt Stoecker, Microsoft Press, 2002, p159)
Quote:
Code:
Dim myTruck As New Truck()
Dim myVehicle As IDrivable
' Casts myTruck to the IDrivable interface
myVehicle = Ctype(IDrivable, myTruck)
(Developing Windows-Based Applications with Microsoft Visual Basic .NET and Microsoft Visual C# NET, Matt Stoecker, Microsoft Press, 2002, p175)

Quote:
Code:
Public Function Add(ByVal first as Integer, ByVal second as _
        Integer)
    Dim Result as Integer
    Result = first + second
End Function
(Developing Windows-Based Applications with Microsoft Visual Basic .NET and Microsoft Visual C# .NET, Matt Stoecker, Microsoft Press, 2002, p20)
DNAunion: There are many others in that book. Yet, note what is said near the beginning.

Quote:
"Every effort has been made to ensure the accuracy of this book and the contents of the companion disc."
(Developing Windows-Based Applications with Microsoft Visual Basic .NET and Microsoft Visual C# .NET, Matt Stoecker, Microsoft Press, 2002, xxvii)

**********************

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:
”A common practice is to use Universal Resource Locators (URLs) for URIs, because the domain names (such as, www.deitel.com) used in URLs are guaranteed to be unique.” (emphasis in original, C#: A Programmer’s Introduction, H. M. Deitel, P. H. Deitel, J. A. Listfield, T. R. Nieto, C. H. Yaeger, and M. Zlatkina, Prentice Hall, 2003, p564)
DNAunion: Yet in another chapter the authors use the “more-correct” terminology.

Quote:
”Any HTML document available on the Web has a Uniform Resource Locator (URL), which indicates the location of the resource.” (emphasis in original, C#: A Programmer’s Introduction, H. M. Deitel, P. H. Deitel, J. A. Listfield, T. R. Nieto, C. H. Yaeger, and M. Zlatkina, Prentice Hall, 2003, p540)
DNAunion: And here’s another from a different MS Press test-prep book.

Quote:
”The Microsoft Certified Professional (MCP) program …

The Microsoft Certified Professional program offers multiple certifications, based on specified areas of expertise:

Microsoft Certified Professional (MCP). …

…[many references to MCPs]

Requirements for Becoming a Microsoft Certified Professional


To become a Microsoft Certified Professional, you must pass…

Microsoft Certified Product (MCP) candidates…”
(Analyzing Requirements and Defining Microsoft .NET Solution Architectures, Karen Szall (Project Editor), Microsoft Press, 2003, pxx - xxiii)
DNAunion: This type of thing isn't limited to computer publications. I used to keep track of errors I found while reading science books too.
DNAunion is offline  
Old 07-16-2003, 06:42 PM   #133
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default Re: Out of Curiosity

Quote:
Deacon Doubtmonger: ... I'm curious how the principles spoken of might apply to a specific situation:

Does anyone know if the specific error in the "killer X-ray machine" software was ever discovered, and could the tenets of program clarity noted here have prevented it?
DNAunion: I don't know about code clarity as much as upfront testing.

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.
DNAunion is offline  
Old 07-16-2003, 06:54 PM   #134
Veteran Member
 
Join Date: Jan 2001
Location: Median strip of DC beltway
Posts: 1,888
Default

Quote:
Originally posted by HeatherD
Beanie's Laws
Quote:
The Second Law

Put a comment after a close BBPe describing the "if, for, loop" clause (collectively known as IFLs) that the BBPe closes.

Over time, the 'guts' inside the clause will expand beyond a screenful or pageful of text, and it's hard to remember what the 3rd BBPe in a cascade of them closes. You are certain to put something new in the wrong place.
I'm of the opinion that if you're doing OOP, and you have any blocks that don't fit entirely on the screen, then you probably need to break it into a couple functions.
NialScorva is offline  
Old 07-16-2003, 10:05 PM   #135
HeatherD
Guest
 
Posts: n/a
Default

Quote:
Originally posted by NialScorva
I'm of the opinion that if you're doing OOP, and you have any blocks that don't fit entirely on the screen, then you probably need to break it into a couple functions.
Agreed, although you don't always know immediately that it's going to get that big.

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.
 
Old 07-17-2003, 05:37 AM   #136
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default

DNAunion: Just picked up another computer programming book and didn't read more than 2 pages before coming across an error.

Quote:
"
Code:
...

list<int> theList;

...

list<int>::iterator iter;

...

for(iter = theList.begin(); iter != theList.end(); iter++)

...
...

We define an iterator of type list<int> to match the container type. As with a pointer variable, we must give an iterator a value before using it. In the for loop we initialize it to iList.begin(), the start of the container."
(Robert Lafore, Object-Oriented Programming in C++: Fourth Edition, Sams, 2002, p759-760)
DNAunion: Is this guy such a novice that he can't read his own code? Nope. Looking at the back cover:

Quote:
"Robert Lafore has been writing books about computer programming since 1982. ... Mr. Lafore holds degrees in mathematics and electrical engineering, and has been active in programming since the days of the PDP-5, when 4K of main memory was considered luxurious. He has worked as a systems programmer at the Lawrence Berkeley Laboratory and started his own software company."
DNAunion is offline  
Old 07-17-2003, 05:47 AM   #137
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default

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.
DNAunion is offline  
Old 07-17-2003, 07:50 AM   #138
Veteran Member
 
Join Date: Jan 2001
Location: Median strip of DC beltway
Posts: 1,888
Default

Quote:
Originally posted by DNAunion
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.
I don't agree with this one. My formulation would be dCrap/dt >=0.
NialScorva is offline  
Old 07-17-2003, 07:55 AM   #139
Veteran Member
 
Join Date: Jan 2001
Location: Median strip of DC beltway
Posts: 1,888
Default

Quote:
Originally posted by DNAunion
DNAunion: Just picked up another computer programming book and didn't read more than 2 pages before coming across an error.



DNAunion: Is this guy such a novice that he can't read his own code? Nope. Looking at the back cover:

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.
NialScorva is offline  
Old 07-17-2003, 10:45 AM   #140
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default

Quote:
NialScorva: 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.
DNAunion: I was careful to say error, not bug.

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).
DNAunion is offline  
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump


All times are GMT -8. The time now is 07:54 PM.

Top

This custom BB emulates vBulletin® Version 3.8.2
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.