[thelist] javascript debug (easy)

Jeff Howden jeff at jeffhowden.com
Mon Jun 6 17:47:46 CDT 2005


Chris,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Christian Heilmann [mailto:codepo8 at gmail.com] 
> 
> They don't hurt though, and other languages require
> them.  [...]
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

Not all languages require them though.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> [...] Keeping the code in a clean standard syntax might
> also help JavaScript to be considered a real skill and
> not something you hack together at will.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

Standard syntax?  According to who?  According to what?  Curly braces are
optional and therefore not including them is *still* "standard".

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> It is very easy to learn JavaScript, as you instantly
> get results in your browser. If you start sloppy, you'll
> just need to learn more later.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

Conciously choosing to omit optional curly braces does not mean you're
sloppy.  Also, never once did I say this was a good idea for a beginner or
someone not comfortable with scripting.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> That is why we got taught now useless languages like
> Pascal in school, as it taught us proper syntax. [...]
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

It taught you proper Pascal syntax which does not equal proper JavaScript
syntax.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> You could apply the same logic to commenting. Why
> comment when the code is easy enough to understand?
> Because you cannot expect the next developer to have
> the same skill level you have and it speeds up
> handovers.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

There's also the crowd that believes that if your code is written clearly
enough that over-commenting actually makes it more difficult to manage as
all the comments break up the natural rhythm you get when parsing the code
by eye.  In other words, learn to write self-documenting code by using
descriptive variable and function names.  In my opinion ever little line of
code does not need commenting.  In fact, comments should be few and far
between otherwise they end up being more of a nuisance when you try to
maintain the code.  Future *possible* gains should not be given priority
over current, *probable* losses.  Comments at the top of a file to introduce
the functionality and other meta data about the file/code block are fine.
However, the only time when commenting should be placed inline is when
you're conquering a particularly nasty obstacle that requires code that is
extremely obtuse.  You can't convince me that it's necessary to insert a
comment for a "window.open()" statement.  If the next developer doesn't know
what that line of code does, he probably doesn't have any business in the
code.

 [>] Jeff Howden
     jeff at jeffhowden.com
     http://jeffhowden.com/



More information about the thelist mailing list