![]() | |
#11
| |||
| |||
|
|
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 |
#12
| ||||
| ||||
|
|
Thomas 'PointedEars' Lahn posted : [snip] 1. "Depreciated script tag usage" a. The word you were looking for is _deprecated_, not "depreciated". Well, if we're being anal, Thomas, "_deprecated_" is not a word. "deprecated" is, though. |
|
b. The term you were looking for is `script' _element_, not "tag". Elements consist of tags (start tag, close tag) and content: http://www.w3.org/TR/REC-html40/intr...t.html#h-3.2.1 Funny thing is, I looked that page up and down buddy, and I didn't see anything about a script _element_ anywhere. Maybe your underscore is broken. |
|
c. Your example `script' elements are empty where they should have content. At least that should be indicated in some way. Pretty sure that's already been under discussion regarding the type attribute. Please read before you post, as you like to say. |
|
One point of recommending against `javascript:' there is that | it cannot provide a fallback to browsers not running Javascript. There are other points that I have also mentioned in my FAQ notes last year. There are also exceptions to be made in special cases. You know what would be even more helpful? A link or even a hint about where your big ole FAQ is for those of us not arrogant enough to read your mind. [more flames] |
#13
| ||||||||
| ||||||||
|
|
On Tue, 01 Jan 2008 18:01:51 +0100, Thomas 'PointedEars' Lahn wrote: |
|
d. "JavaScript1.2" actually means something in NN4; ask Google. I have never seen anyone using "JavaScript1.3", though. I didn't know if that was backwards compatible to browsers today or not. If memory serves me correctly, it changes some of the array methods. |
|
2. 'Using "href:javascript"' | Using the pseudo-protocol javascript in the href is never valid. Not | only is such code not valid HTML, [...] Wrong. The value of the `href' attribute is of type URI. If `javascript:' syntax would be written as an URI, it would certainly be valid there. One point of recommending against `javascript:' there is that | it cannot provide a fallback to browsers not running Javascript. There are other points that I have also mentioned in my FAQ notes last year. There are also exceptions to be made in special cases. Hmmm... This point has me thinking now. I'll have to ponder the best way to phrase the URI issue. "Valid, but not recommended" perhaps. I'll try and find your FAQ notes. If you are feeling generous I'll take a donated URL to it. |
|
4. 'Not ending lines in a semi-colon ";"' The argument in favor of the trailing `;' is flawed in two regards: a) not every line should be ended with a semicolon but every *statement*; I code in C. I know that. Somewhere it got lost between brain and keyboard. Maybe I've been using "one statement per line" scripting languages too much. |
|
b) minifiers should not be used. See previous discussions. I knew that was going to come up. I'm tempted to yank that whole section out, except that style-wise I -really- like having the semicolon there. Code without it grates on me. |
|
5. "Use of eval" | Using eval to parse JSON works well. While there are some security | concerns, they can be easily addressed. There are two other uses where using eval() is considered appropriate. One is making arbitrary computations with user input, Yes, I should mention that. While I've only seen it used for "trivial" calculator applications, I suppose it would be the basis for an Javascript spreadsheet or something. |
|
using try/catch. The try/catch is faster when available. |
|
A reasoning for the statement that the security concerns could be easily addressed is missing. I'll toss in this link: <URL: http://www.json.org/json2.js > In my reading, I haven't heard of anyone finding holes in it. |
#14
| |||||||
| |||||||
|
|
On Tue, 01 Jan 2008 18:01:51 +0100, Thomas 'PointedEars' Lahn wrote: d. "JavaScript1.2" actually means something in NN4; ask Google. I have never seen anyone using "JavaScript1.3", though. I didn't know if that was backwards compatible to browsers today or not. If memory serves me correctly, it changes some of the array methods. |
|
2. 'Using "href:javascript"' [...] There are other points that I have also mentioned in my FAQ notes last year. There are also exceptions to be made in special cases. [...] I'll try and find your FAQ notes. If you are feeling generous I'll take a donated URL to it. |
|
document.write( new Array( '<ul>', ' <li><a href="Search.html">Search<\/a><\/li>', ' <li><a href="Order.html">Order<\/a><\/li>'); ' <li><a href="Help.html">Help<\/a><\/li>'); |
|
'<\/ul>' ).join("") ); } /script I'll agree that is better than the table design, but I was trying to indicate that using Javascript for putting a navigation bar on the screen shouldn't be done. Augmenting one would be OK. |
|
Perhaps a different example would be better. Using Javascript to show a print button or something. |
|
5. "Use of eval" | Using eval to parse JSON works well. While there are some security | concerns, they can be easily addressed. There are two other uses where using eval() is considered appropriate. [...] the other is hiding code from script engines that consider it to be syntactically invalid because they do not support the corresponding language feature. Oh.. there is an idea. That is the second new thought you've tossed into my head here. I'm picturing one code branch that runs slowly with a dozen checks to assert all values are within range and a second code branch using try/catch. The try/catch is faster when available. Is that the kind of thing you mean? |
|
A reasoning for the statement that the security concerns could be easily addressed is missing. I'll toss in this link: <URL: http://www.json.org/json2.js > In my reading, I haven't heard of anyone finding holes in it. |
#15
| |||
| |||
|
|
Are you a programmer or an English teacher? Oh, you're both! That would explain a whole bunch. |
|
This, right here, this is why people get irritated with you, I think. Maybe you just like being a pompous arrogant , I dunno, but most other people don't care for it. You lack that internal filter that says "don't say that, that's what a pontificating, unmitigated ass would say" |
#16
| |||
| |||
|
|
Things you didn't cover: ... Use of "new Function". |
#17
| ||||||||||||
| ||||||||||||
|
|
HTML Comments. Will cause problems when XHTML is used. |
|
Script tag usage. text/javascript is an obsolete (although valid) MIME type. |
|
href:javascript. Drop #1, they all fall into the "Too stupid to know better" category. |
|
document.write. Avoid it. Period. Tables produced with document.write are indicative of an idiot programmer. Buttons/links? document.createElement, .appendChild, no document.write |
|
Local vars. No example of a correct way. |
|
Line ending semicolons. That entire section is incorrect. Do you have a URL for the assertion that Brendan Eich (and others) intentionally left out statement ending semi-colons to "make it easier to learn"? As for minification, that is an indication of bad coding practices. |
|
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. |
|
Browser detection. Spelling error with interfer versus interfere. *nods* |
|
DOCTYPE. No version of IE, not just IE7, handles it that way. Meant to say that. |
|
The use of the "with" operator. Food for thought. I've avoided the with operator since the ancient days |
|
Use of "new Function". I don't see this one too often. |
|
There are, inevitably, more things you didn't cover. Personally, I think a "Best Methods" document is of far more value than a "Bad Methods" document. Then, you aren't showing people bad ways to do things, you are showing them the best ways to do things. And even though I don't agree, totally, with Matt's, I keep it in my signature for that very reason. |
#18
| ||||
| ||||
|
|
Enclosing text with the underline character is used in Usenet to mark text as an underlined correction because in plain text the usual text formatting is not available. Your Thunderbird and mine even have a feature implemented that formats text that way if the parser encounters that syntax. The same goes for `*...*' (bold, usually meant as emphasis) and `/.../' (italic, also emphasis). |

|
Maybe you are an idiot. (See, *now* I said it.) |
|
The reaction of the OP says otherwise. So much for reading. |
|
*PLONK* |
#19
| |||
| |||
|
|
This, right here, this is why people get irritated with you, I think. Maybe you just like being a pompous arrogant , I dunno, but most other people don't care for it. You lack that internal filter that says "don't say that, that's what a pontificating, unmitigated ass would say" [start way off-topic] While I don't know Thomas "PointedEars" personally, and won't speak for him I do know his personality type. Rather than defend him in particular allow me to say a few words for the entire "have-no-people skills but really good with machine" type people. |
#20
| |||
| |||
|
|
I'll try and find your FAQ notes. If you are feeling generous I'll take a donated URL to it. |
![]() |
| Thread Tools | |
| Display Modes | |
| |