HighDots Forums  

RFD: How To Recognize Bad Javascript Code

Javascript JavaScript language (comp.lang.javascript)


Discuss RFD: How To Recognize Bad Javascript Code in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #121  
Old   
Thomas 'PointedEars' Lahn
 
Posts: n/a

Default Re: RFD: How To Recognize Bad Javascript Code - 01-12-2008 , 02:48 PM






Richard Cornford wrote:
Quote:
Anthony Levensalor wrote:
Thomas 'PointedEars' Lahn posted :
This is an excellent tip, thanks!
It's a recipe for disaster. Whenever you use scripts that use
try..catch as-is, compilation will fail with a SyntaxError.
Compilation of the other scripts, that you use along with them
and that don't use try..catch, is not guaranteed.

Maybe not guaranteed but it has generally been observed that a syntax
error in the contents of one script element (or in a resource imported
by a single script element) does not interfere with the successful
interpretation/compilation of syntax error free code in other script
elements (or imported by other script elements) within the same
document. Any cited examples where it did would be important, but in
their absence this seems excessively paranoid.
That would be a voodoo programmer's argument. I don't buy it.


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee


Reply With Quote
  #122  
Old   
McKirahan
 
Posts: n/a

Default Re: How To Recognize Bad Javascript Code - 01-12-2008 , 04:03 PM






"Jeremy J Starcher" <r3jjs (AT) yahoo (DOT) spam.me.not.com> wrote

Quote:
(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.
[snip]

You guys could probably have a field day with this script!
http://www.curvycorners.net/rounded_corners_lite.inc.js


"What is curvyCorners? http://www.curvycorners.net

curvyCorners is a free JavaScript program that will create
on-the-fly rounded corners for any HTML DIV element,
that look as good as any graphically created corners."




Reply With Quote
  #123  
Old   
Thomas 'PointedEars' Lahn
 
Posts: n/a

Default Re: How To Recognize Bad Javascript Code - 01-12-2008 , 04:22 PM



McKirahan wrote:
Quote:
"Jeremy J Starcher" <r3jjs (AT) yahoo (DOT) spam.me.not.com> wrote in message
newsan.2008.01.01.10.28.51.321488 (AT) yahoo (DOT) spam.me.not.com...
(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.

[snip]

You guys could probably have a field day with this script!
http://www.curvycorners.net/rounded_corners_lite.inc.js
A reference to a supposedly bad script posted here
and instantly it becomes 404-compatible. I like that


SCNR

PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7 (AT) news (DOT) demon.co.uk>


Reply With Quote
  #124  
Old   
McKirahan
 
Posts: n/a

Default Re: How To Recognize Bad Javascript Code - 01-12-2008 , 05:11 PM



"Thomas 'PointedEars' Lahn" <PointedEars (AT) web (DOT) de> wrote

Quote:
McKirahan wrote:
"Jeremy J Starcher" <r3jjs (AT) yahoo (DOT) spam.me.not.com> wrote in message
newsan.2008.01.01.10.28.51.321488 (AT) yahoo (DOT) spam.me.not.com...
(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.

[snip]

You guys could probably have a field day with this script!
http://www.curvycorners.net/rounded_corners_lite.inc.js

A reference to a supposedly bad script posted here
and instantly it becomes 404-compatible. I like that
Sorry, my bad; try this:

<URL:http://www.curvycorners.net/examples/demos/rounded_corners_lite.inc.js>




Reply With Quote
  #125  
Old   
Thomas 'PointedEars' Lahn
 
Posts: n/a

Default Re: How To Recognize Bad Javascript Code - 01-12-2008 , 05:30 PM



McKirahan wrote:
Quote:
"Thomas 'PointedEars' Lahn" <PointedEars (AT) web (DOT) de> wrote in message
news:47893DC0.9090501 (AT) PointedEars (DOT) de...
McKirahan wrote:
You guys could probably have a field day with this script!
http://www.curvycorners.net/rounded_corners_lite.inc.js
A reference to a supposedly bad script posted here
and instantly it becomes 404-compatible. I like that

Sorry, my bad; try this:

URL:http://www.curvycorners.net/examples...rs_lite.inc.js
Brrr. Thanks for making my day more interesting ;-)


Regards,

PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann


Reply With Quote
  #126  
Old   
Randy Webb
 
Posts: n/a

Default Re: RFD: How To Recognize Bad Javascript Code v0.3 - 01-13-2008 , 10:25 PM



Dr J R Stockton said the following on 1/12/2008 1:48 PM:
Quote:
In comp.lang.javascript message <7dydnX2_8cW6_hXaRVn_vwA (AT) giganews (DOT) com>,
Sat, 12 Jan 2008 01:51:14, Randy Webb <HikksNotAtHome (AT) aol (DOT) com> posted:
Dr J R Stockton said the following on 1/10/2008 7:13 AM:

But not according to the meaning of its identifier,
No, the identifier is *very* indicative of what it gives you. It gives
you the date the document was last modified.

It seems possible that we might agree that the last-Modified header
corresponds to the current datestamp of the file.
Under most circumstances, yes. Based on Wayne's post, that isn't so sure
anymore.

Quote:
Wayne has recently pointed out that, in some systems, one can change the
content of the file without changing that datestamp.
And that makes it a pretty useless piece of information if it is user
configurable and ranks it with navigator.userAgent for reliability.

Quote:
I have pointed out that one can re-upload with identical content,
causing only the datestamp to change.
And that is what the last-Modified header reads is the datestamp. I have
also pointed out that I can cause it to be changed without uploading.
The group FAQ is a very good example of that. I can log in to the
server, run the wsf file, regenerate the FAQ, and the datestamp will get
changed. It has nothing to do with uploading. The file got replaced and
got a new datestamp. I don't know of a program (at least not Windows/DOS
based) that modifies a file in place. They all replace the file by
over-writing it. Try write protecting a file and modifying it.

Quote:
Therefore, the datestamp is only a weak guide to the real date of the
contents of the page.
Nobody ever said any differently. It is the date the file was last
modified. For *any* reason.

<snip>

Quote:
and such identifiers should be correctly meaningful.
And that identifier is.

Maybe document.serverFileDatestamp for example; fileDate if something
shorter is preferred. Of course, the Last-Modified header needs a
corresponding change. It won't happen; but programmers need to realise
that the names were badly chosen. See "—And He Built a Crooked House—".
Most in the language are badly chosen. It doesn't change what they are
or what they do. And ignorance on the part of the programmer won't
change that.

Quote:
That corresponds to the meaning of "misnomer".
document.lastModified is nowhere near a misnomer. It is precisely what
it says it is.

Not for those who know what "modified" means in ordinary English.
Yes it does. Perhaps you could post a definition of what you think
"modified" means in "ordinary English".

To change in form or character; alter.

And when you save a file, it is "altered" in that it was replaced.

Quote:
You are the one that seems to think it always indicates "potential
significance" which isn't what the property holds.

I have been saying that the naive scripter may believe that; and that it
is quite likely that the reader of a page whose source contains
something like
document.write("Last Modified at : ", document.lastModified, "<br>")
will believe that what he sees was last changed then.
Only you could take that example of a simple problem that I showed,
accuse me of lack of insight, and then totally miss the point.

Besides, if the file was changed - for whatever reason - then the page
will tell the user precisely what the programmer told it to tell the
user and the date will be accurate.

Quote:
Out of curiosity though, could you explain what rules you think an OS
should follow to know whether a document has truly been modified -
according to your expectations - versus minor corrections?


It cannot do so. Therefore, it should not emit dates in association
with identifiers which imply that that is the case.
It emits dates based on what the property is supposed to give.

Quote:
The information needs to be inserted at the place where the
document is actually edited.
You are confusing "edited" and "modified". They are not the same.


--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


Reply With Quote
  #127  
Old   
Dr J R Stockton
 
Posts: n/a

Default Re: RFD: How To Recognize Bad Javascript Code v0.3 - 01-14-2008 , 01:20 PM



In comp.lang.javascript message <LIudnbmF8MmQeRfaRVn_vwA (AT) giganews (DOT) com>,
Sun, 13 Jan 2008 23:25:50, Randy Webb <HikksNotAtHome (AT) aol (DOT) com> posted:
Quote:
Yes it does. Perhaps you could post a definition of what you think
"modified" means in "ordinary English".
modify verb (modifies, modified, modifying) 1 to change the form or
quality of something, usually only slightly. 2 grammar to act as a
modifier of (a word). 3 to moderate. modifiable adj. modification noun 1
the act of modifying or state of being modified. 2 a change of form or
condition; something that has been modified • a few modifications to the
original plan.
ETYMOLOGY: 14c: from French modifier, from Latin modificare.

Quote:
And when you save a file, it is "altered" in that it was replaced.
If the saved version has the same content, byte for byte, it is not
modified.

If a new version of an HTML file displays identically in a browser, it
is not modified.

If the content of a file is altered, but the datestamp is unchanged, the
file is modified.

Therefore, Last-Modified and lastModified are misnomers.

misnomer noun 1 a wrong or unsuitable name. 2 the use of an incorrect
name or term.
ETYMOLOGY: 15c: from French mesnommer to misname, from mes- mis- +
nommer to name, from Latin nominare.




ASIDE: LZZ is modified, matching the mod to LZ. <js-date9.htm>.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
I find MiniTrue useful for viewing/searching/altering files, at a DOS prompt;
free, DOS/Win/UNIX, <URL:http://www.idiotsdelight.net/minitrue/> unsupported.


Reply With Quote
  #128  
Old   
Randy Webb
 
Posts: n/a

Default Re: RFD: How To Recognize Bad Javascript Code v0.3 - 01-16-2008 , 12:42 AM



Dr J R Stockton said the following on 1/14/2008 2:20 PM:
Quote:
In comp.lang.javascript message <LIudnbmF8MmQeRfaRVn_vwA (AT) giganews (DOT) com>,
Sun, 13 Jan 2008 23:25:50, Randy Webb <HikksNotAtHome (AT) aol (DOT) com> posted:
Yes it does. Perhaps you could post a definition of what you think
"modified" means in "ordinary English".

modify verb (modifies, modified, modifying) 1 to change the form or
quality of something, usually only slightly. 2 grammar to act as a
modifier of (a word). 3 to moderate. modifiable adj. modification noun 1
the act of modifying or state of being modified. 2 a change of form or
condition; something that has been modified • a few modifications to the
original plan.
ETYMOLOGY: 14c: from French modifier, from Latin modificare.
I truly believe, although I could be wrong, that this is the first time
I have ever seen anybody give a definition that directly contradicts
there own argument and then they stick to there argument. Truly
impressive. All I can say is "WOW!".

Quote:
And when you save a file, it is "altered" in that it was replaced.

If the saved version has the same content, byte for byte, it is not
modified.
The OS has no way of knowing that. It is replace. The date it was saved
has changed (which is part of the file), so, the file has been
"modified' (By your own definition).

Quote:
If a new version of an HTML file displays identically in a browser, it
is not modified.
You are making this too easy.

Create a basic HTML File and put this link in it:

<a href="somewhere.html">Go there</a>

Save it.
Edit it and change the link to this:

<a href="somewhereElse.html">Go there</a>

According to your statement, it wasn't "modified" because it "display
identically".

You're making this too too easy on me John.

You are confusing displayed content and file content. They are not the same.

Quote:
If the content of a file is altered, but the datestamp is unchanged, the
file is modified.
If a file is modified and the datestamp is not modified, you don't have
a misnomer, you have a broken/buggy OS.

Quote:
Therefore, Last-Modified and lastModified are misnomers.
No, the only way it could remotely be a misnomer is if you have a broken
OS and that isn't a misnomer, it is a broken/buggy OS.


Sidenote: LZ is a misnomer though.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


Reply With Quote
  #129  
Old   
Dr J R Stockton
 
Posts: n/a

Default Re: RFD: How To Recognize Bad Javascript Code v0.3 - 01-16-2008 , 12:49 PM



In comp.lang.javascript message <hc-dnfquMMeJOhDa4p2dnAA (AT) giganews (DOT) com>,
Wed, 16 Jan 2008 01:42:30, Randy Webb <HikksNotAtHome (AT) aol (DOT) com> posted:
Quote:
The OS has no way of knowing that. It is replace. The date it was saved
has changed (which is part of the file), so, the file has been
"modified' (By your own definition).

The datestamp is not part of the file.

--
(c) John Stockton, Surrey, UK. ???@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Check boilerplate spelling -- error is a public sign of incompetence.
Never fully trust an article from a poster who gives no full real name.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.