Thread: One More
View Single Post
  #8 (permalink)  
Old May 27th, 2010, 06:25 PM
Old Pedant Old Pedant is offline
Friend of Wrox
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts

while (document.QuestionForm.radQuestionChoice[answer].checked != true)

Now I do not claim to be a programmer; that is why I purchased Beginning JavaScript, but shouldn't a while loop start with a{ and end with a }.
I'd agree with you on this one. Clearly the braces are not needed, according to the language definition, but omitting them is pretty bad practice and easily leads to later problems when you need to go modify code.

Re <BR> vs. <br> and such: It's really funny. When I first learned HTML back in the dark ages (1997 or so), all of the style guidelines *told* us to use all capitals for HTML tags! And we were even encouraged to omit </option> and </p> tags and such just to save bytes (after all, most people were till using slow modems...I know that my top speed at that time via phone line tended to be around 15K baud...that's 1.5 K bytes per second....and was often much slower).

Then along came XML and XHTML and now, depending on the DOCTYPE, you *must* use all lower case tags and all tags *must* have closures (e.g., <br/> and </p> and so on).

So I suspect that a lot of the code in that book suffered from having originated years before in maybe version 1.

I know I have code on some of my web sites that I wrote back then and I have to shudder when I look at it.

I've never seen this book, by the way. I *think* I saw version 1, many years ago. I think an office mate had it. But I can't say I ever tried to learn JavaScript from any book, so I'm surely not a good one to critique any of them.


As a complete and utter aside: Back in (I think) 1998, there was a contest called the "5K Web Page" contest. The goal was to create a web page in no more than 5K bytes (5120 bytes...taking the K the correct way). And there was good reason for it! The originators decided that too many people were producing bloated much as 20 and 30K bytes...that were just taking too long to load. So by keeping the page sizes down to 5K bytes, most people would be able to load them in under 10 seconds. You should *SEE* the code from that contest! My own code is nearly impossible for me to read today, because it's so obscure and so ugly by today's standards.

We now return you to our regularly scheduled programming.
Reply With Quote