![]() | |
#41
| |||
| |||
|
|
Thomas 'PointedEars' Lahn wrote: a. The word you were looking for is _deprecated_, not "depreciated". Actually, "depreciated" is the correct word. Some moron about 75 years ago decided that "deprecated" sounded more kewl, and got the two words hopelessly confused. Properly, to deprecate something is to pray to be protected from it, ee.g.: |
#42
| |||
| |||
|
|
In article <477ae913$0$13902$607ed4bc (AT) cv (DOT) net>, "John W. Kennedy" <jwkenne (AT) attglobal (DOT) net> wrote: Thomas 'PointedEars' Lahn wrote: a. The word you were looking for is _deprecated_, not "depreciated". Actually, "depreciated" is the correct word. Some moron about 75 years ago decided that "deprecated" sounded more kewl, and got the two words hopelessly confused. Properly, to deprecate something is to pray to be protected from it, ee.g.: Wrong on all counts. You need to find yourself a better dictionary. "Deprecate" means to belittle; "depreciate" means to reduce the value of. The Latin *root* of "deprecate" means to pray to be protected from, but that is not its English meaning, properly or otherwise. |
#43
| |||||||
| |||||||
|
|
On Jan 1, 1:30 pm, Randy Webb <HikksNotAtH... (AT) aol (DOT) com> wrote: Jeremy J Starcher said the following on 1/1/2008 5:37 AM: On Tue, 01 Jan 2008 05:28:51 -0500, Jeremy J Starcher wrote: (Request for Discussion) I've put together a guide that I hope will help novice coders avoid the same hair pulling that I went through. And it would really help if I included URL:http://www.mopedepot.com/jjs/HowToRe...criptCode.html HTML Comments. Will cause problems when XHTML is used. Script tag usage. text/javascript is an obsolete (although valid) MIME type. But you have to use it for now if you want valid markup. |
|
href:javascript. Drop #1, they all fall into the "Too stupid to know better" category. document.write. Avoid it. Period. For the most part. There are times when it comes in handy. I have recently been working on test page for some proposed Code Worth Recommending and I didn't want the HTML version to break in ancient browsers that don't feature createElement. Of course, there is no choice when using XHTML. |
|
As for minification, that is an indication of bad coding practices. I don't follow you there. The project I am currently working on builds a library from various modules. If all are included, the file size with comments and white-space is almost 200K (and will get bigger in the future as more comments are added.) Running it through the YUI "compressor" (minifier/obfuscator) reduces it to 90K. Granted, this should only be done when the code is deployed on a production server. One irritation is that I have to re-test everything to make sure that minification didn't break something, but I have yet to have a problem with this particular minifier. Of course, I run the source through JSLint to catch typos and missing semi-colons beforehand. |
|
Use of eval. The use of eval itself usually indicates bad coding, but not always. Whether it is a bad use of it or not depends on how it is used. And a beginner can't possibly know. Is this a good use of eval? function convertToDecimal(fraction){ return eval(fraction) } I don't like it. |
|
Where fraction is a fraction that you need converted to decimal? It can be written like this: function convertToDecimal(fraction){ var numerator = fraction.substring(0,fraction.lastIndexOf('/')) var denominator = fraction.substring(fraction.lastIndexOf('/')+1) return (numerator/denominator) } Testing shows that eval is a lot quicker but a newbe could never know that it was actually a "good use" of eval. The second version could be made more efficient. I don't know whether it could approach the speed of using eval, but I would still prefer it. |
|
Browser detection. Spelling error with interfer versus interfere. DOCTYPE. No version of IE, not just IE7, handles it that way. JSLint. JSLint is a tool that attempts to make sure you code according to the preference and style that Douglas Crockford prefers. You can filter out the stylistic concerns. Certainly I don't use the strict whitespace option, but overall, I find it an invaluable tool. |
|
All it takes is one mistaken keystroke to introduce an unintended global variable (of course, Firebug spots those in its DOM view.) Then there are unused variables, out of scope references, unfiltered for-in loops, etc. I think it is a must for any project with more than a few dozen lines of code. |
#44
| |||
| |||
|
|
David Mark said the following on 1/1/2008 5:10 PM: On Jan 1, 1:30 pm, Randy Webb <HikksNotAtH... (AT) aol (DOT) com> wrote: Jeremy J Starcher said the following on 1/1/2008 5:37 AM: On Tue, 01 Jan 2008 05:28:51 -0500, Jeremy J Starcher wrote: (Request for Discussion) I've put together a guide that I hope will help novice coders avoid the same hair pulling that I went through. And it would really help if I included URL:http://www.mopedepot.com/jjs/HowToRe...criptCode.html HTML Comments. * Will cause problems when XHTML is used. Script tag usage. * text/javascript is an obsolete (although valid) MIME type. But you have to use it for now if you want valid markup. I do? script type="" alert('Just checking') /script The W3 validator validates it just fine. And all the PC based browsers I tested it on happily gave me the alert. So much for "valid HTML", eh? |
#45
| |||
| |||
|
|
On Jan 1, 10:16 pm, Randy Webb <HikksNotAtH... (AT) aol (DOT) com> wrote: David Mark said the following on 1/1/2008 5:10 PM: On Jan 1, 1:30 pm, Randy Webb <HikksNotAtH... (AT) aol (DOT) com> wrote: Jeremy J Starcher said the following on 1/1/2008 5:37 AM: On Tue, 01 Jan 2008 05:28:51 -0500, Jeremy J Starcher wrote: (Request for Discussion) I've put together a guide that I hope will help novice coders avoid the same hair pulling that I went through. And it would really help if I included URL:http://www.mopedepot.com/jjs/HowToRe...criptCode.html HTML Comments. Will cause problems when XHTML is used. Script tag usage. text/javascript is an obsolete (although valid) MIME type. But you have to use it for now if you want valid markup. I do? script type="" alert('Just checking') /script The W3 validator validates it just fine. And all the PC based browsers I tested it on happily gave me the alert. So much for "valid HTML", eh? That is valid markup (but an odd choice) and as there is type indicated, browsers use the default of JavaScript. This is valid too: script type="application/javascript" ... /script But is not recommended as it could confuse older browsers. So you are left with two choices ("text/javascript" or ""), only one of which is clear. |
#46
| |||
| |||
|
|
David Mark said the following on 1/1/2008 10:34 PM: On Jan 1, 10:16 pm, Randy Webb <HikksNotAtH... (AT) aol (DOT) com> wrote: David Mark said the following on 1/1/2008 5:10 PM: On Jan 1, 1:30 pm, Randy Webb <HikksNotAtH... (AT) aol (DOT) com> wrote: Jeremy J Starcher said the following on 1/1/2008 5:37 AM: On Tue, 01 Jan 2008 05:28:51 -0500, Jeremy J Starcher wrote: (Request for Discussion) I've put together a guide that I hope will help novice coders avoidthe same hair pulling that I went through. And it would really help if I included URL:http://www.mopedepot.com/jjs/HowToRe...criptCode.html HTML Comments. * Will cause problems when XHTML is used. Script tag usage. * text/javascript is an obsolete (although valid) MIME type. But you have to use it for now if you want valid markup. I do? script type="" alert('Just checking') /script The W3 validator validates it just fine. And all the PC based browsers I tested it on happily gave me the alert. So much for "valid HTML", eh? That is valid markup (but an odd choice) and as there is type indicated, browsers use the default of JavaScript. *This is valid too: script type="application/javascript" ... /script But is not recommended as it could confuse older browsers. *So you are left with two choices ("text/javascript" or ""), only one of which is clear. As for "validity", this is valid HTML: script type="HikkScript" |
#47
| |||
| |||
|
|
Certainly there are mobile devices (and other agents) using script engines that do not parse try-catch clauses. A good rule of thumb is to relegate the use of try-catch to scripts that you can afford to lose in such browsers. In other words, if you have enhancements that will work in virtually any browser (e.g. form validation), don't lump them in with or make them reliant upon scripts that feature try-catch clauses (e.g. Ajax, Flash.) That way agents that ignore the scripts with try-catch clauses can still make use of the other enhancements. |
#48
| |||
| |||
|
|
(Request for Discussion) I've put together a guide that I hope will help novice coders avoid the same hair pulling that I went through. |
#49
| |||
| |||
|
|
If your title bar does not indicate version 0.2, reload the page. Usually the F5 key on most browsers, or the 'reload' button. http://www.mopedepot.com/jjs/HowToRe...criptCode.html |
#50
| |||
| |||
|
|
David Mark posted : Certainly there are mobile devices (and other agents) using script engines that do not parse try-catch clauses. A good rule of thumb is to relegate the use of try-catch to scripts that you can afford to lose in such browsers. In other words, if you have enhancements that will work in virtually any browser (e.g. form validation), don't lump them in with or make them reliant upon scripts that feature try-catch clauses (e.g. Ajax, Flash.) That way agents that ignore the scripts with try-catch clauses can still make use of the other enhancements. This is an excellent tip, thanks! |
|
I've got my current XMLHttpRequest objects instantiating in try-catch blocks. |
![]() |
| Thread Tools | |
| Display Modes | |
| |