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
  #91  
Old   
David Mark
 
Posts: n/a

Default Re: RFD: How To Recognize Bad Javascript Code - 01-03-2008 , 07:40 PM






On Jan 3, 4:29*pm, Dr J R Stockton <j... (AT) merlyn (DOT) demon.co.uk> wrote:
Quote:
In comp.lang.javascript message <8d803126-36b2-4752-8353-499dfd387e01@e6
g2000prf.googlegroups.com>, Wed, 2 Jan 2008 16:58:43, David Mark
dmark.cins... (AT) gmail (DOT) com> posted:





On Jan 2, 4:00*pm, Dr J R Stockton <j... (AT) merlyn (DOT) demon.co.uk> wrote:
In comp.lang.javascript message <8331b1ee-5f11-4391-bdc6-05d427912e5f@e2
6g2000hsh.googlegroups.com>, Tue, 1 Jan 2008 16:35:16, David Mark
dmark.cins... (AT) gmail (DOT) com> posted:

*Another reason to minify is
that compression (when available) will only reduce comment bulk,
whereas minification eliminates it.

ISTM wrong always to use something that eliminates all comment, even on
a fully-commercial page not intended to be read. *Comment explaining the
code should be removed; but comment identifying the source and date can
be worth retaining.

Absolutely. *I typically add copyright and version information at the
top after minification.

But then you have no guarantee of consistent correctness in matching the
minified version with the correct original, unless the process is
adequately automated. *Anything a human can do, he/she can occasionally
I use a batch file to call the minifier and then tack on the
copyright, etc.



Reply With Quote
  #92  
Old   
David Mark
 
Posts: n/a

Default Re: RFD: How To Recognize Bad Javascript Code v0.2 - 01-03-2008 , 07:45 PM






On Jan 3, 4:52*pm, Dr J R Stockton <j... (AT) merlyn (DOT) demon.co.uk> wrote:
Quote:
In comp.lang.javascript message <cff62c4b-e5fc-4882-90f4-ab0242cc186a@i3
g2000hsf.googlegroups.com>, Wed, 2 Jan 2008 20:53:30, David Mark
dmark.cins... (AT) gmail (DOT) com> posted:





On Jan 2, 11:21*pm, Jeremy J Starcher <r3... (AT) yahoo (DOT) com> wrote:
On Wed, 02 Jan 2008 12:18:12 -0500, Randy Webb wrote:
If it is going into a "Bad Code" document then shouldn't you endeavorto
show the best possible way to do it? And that is why I said that I
thought that a Best Practices document is a better way to go than a Bad
Practices document. The Best document can have an end to it, the Bad
document can never ever cover all the bad code you might (and probably
will) encounter on the web.

Its not my goal to show every single thing that can make for bad code,
but I do believe that there are a /small/ and /limited/ number of things
that truly awful code will have in common.

When I am trying to find a code snippet that will do something I need,
the *first* thing I do is search for the variable "isIE". * If not found,

Similarly, any hits for "userAgent" indicate that the code can be
dismissed out of hand.

Not necessarily. *What's wrong with a page, originated by programmer A
but nowadays maintained by good programmer B, that contains

* * * * // Code replaced, B, yyyy-mm-dd : was
* * * * /* ... userAgent ... */
* * * * <feature-testing code
Fair enough. Finding it in a comment is okay. Finding it parsed by
code and used in branches indicates supreme incompetence. It is
amazing to me that virtually the entire Web (and especially "Web 2.0")
runs on code that treats the presence of "msie" in the userAgent
string as meaningful information.



Reply With Quote
  #93  
Old   
Tim Streater
 
Posts: n/a

Default Re: [OT] depreciate vs. deprecate - 01-04-2008 , 04:01 AM



In article <Xns9A1AA0E435FDFlostthreads (AT) 216 (DOT) 196.97.136>,
"-Lost" <maventheextrawords (AT) techie (DOT) com> wrote:

Quote:
Response to Tim Streater <tim.streater (AT) dante (DOT) org.uk>:

In article <qqOdnWNTP6hgb-HaRVn_vwA (AT) giganews (DOT) com>,
Randy Webb <HikksNotAtHome (AT) aol (DOT) com> wrote:

Evertjan. said the following on 3/1/2008 7:33 AM:

snip

This is certainly NOT off topic in this NG.

You don't think that the meaning of words, and the history of the
meanings, is off-topic here? Sounds more like it would be better
in a group dedicated to the meanings and history of words.

I didn't see the posts that led to the above, but if the use of
the word 'deprecate' is appropriate in this NG, as would seem very
likely, then a brief discussion which might avoid the incorrect
use of a similar sounding or looking word is relevant here.

That sounds like a clever attempt at semantics and the production of
off-topic replies.

If for example I discuss that a woman I once knew got turned on by
talking about code, programming, and hence JavaScript -- would sexual
geek fetishes be on-topic here?

That sounds like a clever attempt at semantics and the production of
off-topic replies.


Reply With Quote
  #94  
Old   
-Lost
 
Posts: n/a

Default Re: [OT] depreciate vs. deprecate - 01-04-2008 , 02:04 PM



Response to Tim Streater <tim.streater (AT) dante (DOT) org.uk>:

Quote:
That sounds like a clever attempt at semantics and the production
of off-topic replies.
snip
That sounds like a clever attempt at semantics and the production
of off-topic replies.
Glad you agree!

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.


Reply With Quote
  #95  
Old   
Eric B. Bednarz
 
Posts: n/a

Default Re: RFD: How To Recognize Bad Javascript Code - 01-04-2008 , 07:31 PM



Thomas 'PointedEars' Lahn <PointedEars (AT) web (DOT) de> writes:

Quote:
Eric B. Bednarz wrote:

The terms you were looking for are ‘start-tag’ and ‘end-tag’. See ISO
8879, clause 7.3, or otherwise not the FAQ, part 5 (and also part 4, now
that I come to think about it .

There is no requirement for a hyphen in compound words in English.

You are merely splitting hairs
Not quite, I’m merely making fun of those who fancy nitpicking.
As a rule of thumb, I’d say that every correction spawns at least two
new errors, everything I write myself included.

Quote:
while I was pointing out the use of wrong
technical terms -- a slight, but important difference.
Than it would be better to use the correct ones, which can be found in
the mentioned ISO standard; opinions (we are not talking French here)
about ‘English’ hyphenation conventions are covered in chapter 7 of
The Chicago Manual of Style, 15th edition (and “close” isn’t even close,
really .


--
Quote:
|| hexadecimal EBB
o-o decimal 3771
--oOo--( )--oOo-- octal 7273
205 goodbye binary 111010111011


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

Default Re: RFD: How To Recognize Bad Javascript Code - 01-06-2008 , 10:05 PM



Dr J R Stockton said the following on 1/3/2008 11:39 AM:
Quote:
In comp.lang.javascript message <cLWdnSPqp_3QZ-ba4p2dnAA (AT) giganews (DOT) com>,
Wed, 2 Jan 2008 15:56:23, Randy Webb <HikksNotAtHome (AT) aol (DOT) com> posted:
Dr J R Stockton said the following on 1/2/2008 7:14 AM:
<snip>

Quote:
It is only bad data design that makes the use of 'eval' seem appropriate
for that purpose.
It isn't bad data design at all. When you need a number in two forms -
both decimal and fraction - and you choose which one to use where, the
best way is to keep the fraction as a string and convert it to decimal
when needed.

Wrong, unless the amount of decimal is very small.
Wrong.

Quote:
A rational fraction is an ordered pair of numbers (as a complex number is),
and should be held as such.
How a fraction should be held in programming code is dependent on what
is being done with it. If you want to believe, without doubt, that
holding it as a pair of numbers, then believe that. Can you show me how
to make the value of a select element to be of type Number though? If
you can, then your statement has some merit. If you can't (and you
can't), then your statement has limited merit because it is flawed.

Quote:
But remember : my aim is not to make you understand, but to give
everyone else no reason to be deceived.
It is a good thing you don't aim to make me understand your way of
thinking, you would fail. Your attempt is obvious to anyone who has read
more than 4 or 5 of your posts, and you failed.

--
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
  #97  
Old   
Jeremy J Starcher
 
Posts: n/a

Default RFD: How To Recognize Bad Javascript Code v0.3 - 01-07-2008 , 03:58 AM



On Tue, 01 Jan 2008 05:37:14 -0500, Jeremy J Starcher 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.

URL: http://www.mopedepot.com/jjs/HowToRe...criptCode.html
Version 0.3 is up.

Once again, I thank all of you for your comments, suggestions and
encouragement.

I know that I did not include a lot of things that were mentioned. While
most, if not all, were markers of "not great" code, I had to remain on
task and on focus. I believe that I have distilled enough
easy-to-digest-points for the complete novice to follow.

If any of the powers that be would wish to move this document, once
finalized, into a larger collection of recognized Javascript writings I
would be open to the idea. We can discuss it here or in email.




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

Default Re: RFD: How To Recognize Bad Javascript Code v0.3 - 01-07-2008 , 04:11 PM



Jeremy J Starcher said the following on 1/7/2008 4:58 AM:
Quote:
On Tue, 01 Jan 2008 05:37:14 -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.

URL: http://www.mopedepot.com/jjs/HowToRe...criptCode.html

Version 0.3 is up.

Once again, I thank all of you for your comments, suggestions and
encouragement.

I know that I did not include a lot of things that were mentioned. While
most, if not all, were markers of "not great" code, I had to remain on
task and on focus. I believe that I have distilled enough
easy-to-digest-points for the complete novice to follow.

If any of the powers that be would wish to move this document, once
finalized, into a larger collection of recognized Javascript writings I
would be open to the idea. We can discuss it here or in email.
Most of these, if not all, are grammar and typo related:

"If you are new to Javascript and want to learn from example", should
be, IMO, examples.

Why? Most Javascript examples found found on the web.....

estimate, not estimage.

Still spelled depreciated, deprecated is the correct word.

"The recommended way write a script tag in HTML 4"

way to write a.....

Do a search/replace on depreciated. Some are corrected to deprecated,
some aren't.

href="javascript:"

In the "best case", the worst ill effect is that animations stop being
animated in the page.


document.write("<p>This page last updated:" + document.lastModified) +
"<\/p>");

Extra ) after lastModified.

"This can cause result in hard-to-find bugs and unpredictable behavior."

Either remove cause or re-word the sentence.

"will suddenly fail Strictly"

Grammar. No period at the end of the sentence.

intra net is spelled intranet.

"An summary of things to avoid."

A summary.....



--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?


Reply With Quote
  #99  
Old   
Jeremy J Starcher
 
Posts: n/a

Default Re: RFD: How To Recognize Bad Javascript Code v0.3 - 01-07-2008 , 04:50 PM



On Mon, 07 Jan 2008 17:11:40 -0500, Randy Webb wrote:

Quote:
Jeremy J Starcher said the following on 1/7/2008 4:58 AM:
On Tue, 01 Jan 2008 05:37:14 -0500, Jeremy J Starcher wrote:
Most of these, if not all, are grammar and typo related:
Bad fingers! Bad!

The joys of being dyslexic. Normally, one of my friends is willing to
proofread things for me and catch all of that stuff before it hits the
world, but she won't proofread tech documents.

I even did the old "get away from it for a few days" trick to see if I
could spot anything I didn't catch last time through. Hopefully, edits
should be just about over.

(Mentally, I know there is a difference between "depreciated" and
"deprecated" but I don't *see* it, if that makes any sense.)

Thanks for the patience.


Reply With Quote
  #100  
Old   
Wayne
 
Posts: n/a

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



Jeremy J Starcher wrote:
Quote:
On Mon, 07 Jan 2008 17:11:40 -0500, Randy Webb wrote:

Jeremy J Starcher said the following on 1/7/2008 4:58 AM:
On Tue, 01 Jan 2008 05:37:14 -0500, Jeremy J Starcher wrote:
Most of these, if not all, are grammar and typo related:

Bad fingers! Bad!

The joys of being dyslexic. Normally, one of my friends is willing to
proofread things for me and catch all of that stuff before it hits the
world, but she won't proofread tech documents.

I even did the old "get away from it for a few days" trick to see if I
could spot anything I didn't catch last time through. Hopefully, edits
should be just about over.

(Mentally, I know there is a difference between "depreciated" and
"deprecated" but I don't *see* it, if that makes any sense.)

Thanks for the patience.
You should join the group "DAM", Mothers Against Dyslexia.

-Wayne


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.