Updated Conventions Document

  • Thread starter Martin Rinehart
  • Start date
G

Gregor Kofler

David Mark meinte:
After all, it was written by the authors of
Dojo.

[snip]

An excerpt:

"Names representing types (classes) MUST be nouns and written using
CamelCase capitalization:

Account, EventHandler"

What?!

I've another one for you - enjoy:

http://jsdoc.sourceforge.net/#tagref

Ain't that nifty? By throwing in JSDoc JS suddenly knows "classes"
subclasses "extending" superclasses, "private" classes, "members" of
classes, class dependencies, etc.

Gregor
 
D

David Mark

David Mark meinte:
After all, it was written by the authors of
Dojo.

An excerpt:
"Names representing types (classes) MUST be nouns and written using
CamelCase capitalization:
Account, EventHandler"

I've another one for you - enjoy:

In what sense?

Ah, you were making a joke. I hadn't heard that one before.
Ain't that nifty? By throwing in JSDoc JS suddenly knows "classes"
subclasses "extending" superclasses, "private" classes, "members" of
classes, class dependencies, etc.

Pure genius. It is like they made it a whole new language. Those
guys should write a library! :)
 
T

Thomas 'PointedEars' Lahn

David said:
Martin said:
I have added the "Dojo Style Guide" to my conventions compilation,
here:

http://www.MartinRinehart.com/articles/javascript-conventions.html

The Dojo document is more comprehensive than Crockford.

But is it useful advice? After all, it was written by the authors of
Dojo.

[snip]

An excerpt:

"Names representing types (classes) MUST be nouns and written using
CamelCase capitalization:

Account, EventHandler"

What?!

You need to translate that with scriptkiddie.sed first:

s/Names/Identifiers/
s/types (classes)/constructors/

Then it makes sense and I can only second it (and have done so before).

One common JS/ES beginner's mistake is to confuse primitive data types and
constructors and prototype objects because in other languages, particularly
Java, each constructor is related to a class which is considered a type of
its own.

Not so in implementations of ECMAScript until including Edition 3:
a user-defined constructor, e.g.

function Foo()
{
}

refers to a *Function* object (which could be said to be of type "function"
since that is what the `typeof' operation applied on it yields), and objects
created using this constructor with e.g.

new Foo()

are, strictly speaking, (possibly augmented) *Object* objects (however, I,
too, tend to use the shortcut term "Foo object" instead, for the lack of a
better, equally concise term). In any case, the typeof operation on them
yields "object", so they could said to be of that type.

It would also appear that the ECMAScript Language Specification itself
supports misunderstanding as it defines e.g. a (primitive) "String type"
[section 8.4], a String() function that converts to the "String type"
[15.5.1], and a String() constructor that creates a "String object"
[15.5.2]. This ambiguity is hard to understand particularly for beginners,
and one can only hope that Brendan Eich's suggestion on how to fix it will
eventually be part of the next edition of ECMAScript (3.1/4).


PointedEars
 
J

John G Harris

David said:
Martin said:
I have added the "Dojo Style Guide" to my conventions compilation,
here:

http://www.MartinRinehart.com/articles/javascript-conventions.html

The Dojo document is more comprehensive than Crockford.

But is it useful advice? After all, it was written by the authors of
Dojo.

[snip]

An excerpt:

"Names representing types (classes) MUST be nouns and written using
CamelCase capitalization:

Account, EventHandler"

What?!

You need to translate that with scriptkiddie.sed first:

s/Names/Identifiers/
s/types (classes)/constructors/

Then it makes sense and I can only second it (and have done so before).
<snip>

An identifier is a syntactic unit : a string that obeys certain rules.

A name need not be an identifier. For instance, some people want
properties with names such as items[] .

You could have pointed out that EventHandler is not a noun, it's a noun
phrase.

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top