Node naming conventions

124 views
Skip to first unread message

Julien Polo

unread,
Oct 26, 2010, 4:34:32 AM10/26/10
to nodejs
Hi,

There's lot of packages, lots of different applications and as
developer on nodejs I was just wondering if there are some naming
conventions in nodejs?

As you can read on this thread, we discussed about the name
"nodelint":
http://github.com/tav/nodelint/issues#issue/11

So the question is, should we name it nodelint, node-lint, node_lint,
or anything else?

At first it does not seems important but, conventions are really
important for a new platform. It allows developer to "forget" the API
and just code as he/she thinks (nodejs should not make the same
mistakes as PHP with the strreplace, str_dostuff etc, ...)

Thanks,

Micheil Smith

unread,
Oct 26, 2010, 5:05:35 AM10/26/10
to nod...@googlegroups.com
Hi Julien,

It doesn't really matter how modules are named within node.js, as when you only
ever use the name at two different times:
1) When installing the module, usually:
npm install [module]

2) When requiring the module:
var MyModule = require("module-name");

As you can rename what you reference the module contents as when you require it,
the naming of the module isn't super important.

Generally I use node-[module-name], if it's a specific client or server for a protocol, I
suffix it appropriately, as to avoid confusion when people are looking for modules.

Hopefully this helps somewhat,

Yours,
Micheil Smith
--
BrandedCode.com

> --
> You received this message because you are subscribed to the Google Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.
>

Ryan Gahl

unread,
Oct 26, 2010, 10:36:17 AM10/26/10
to nod...@googlegroups.com
the rule is: you must name all modules "david-hasselfhoff"

very simple, elegant rule

---
Warm Regards,
Ryan Gahl

Dominic Tarr

unread,
Oct 26, 2010, 5:29:17 PM10/26/10
to nod...@googlegroups.com
lower-case with hyphens is easy to read and type, 
prefixing with node is annoying.

Dean Landolt

unread,
Oct 26, 2010, 5:33:35 PM10/26/10
to nod...@googlegroups.com
On Tue, Oct 26, 2010 at 5:29 PM, Dominic Tarr <domini...@gmail.com> wrote:
lower-case with hyphens is easy to read and type, 

And is even more important now that node is targeting first class windows support -- things are painful when you start mixing case on case-insensitive filesystems 
 
prefixing with node is annoying.

Amen. The exception would probably be libs that enhance core node features (like node-inotify). Just because you're targeting node today doesn't mean you won't be adding support for running in the browser tomorrow.

Corey Hart

unread,
Oct 26, 2010, 6:13:01 PM10/26/10
to nodejs
And if they manage to consolidate their plugin to a single script,
only 42 lines long. The module must be name "the-hoff"

On Oct 26, 7:36 am, Ryan Gahl <ryan.g...@gmail.com> wrote:
> the rule is: you must name all modules "david-hasselfhoff"
>
> very simple, elegant rule
>
> ---
> Warm Regards,
> Ryan Gahl
>
> > nodejs+un...@googlegroups.com<nodejs%2Bunsu...@googlegroups.com>
> > .
> > > For more options, visit this group at
> >http://groups.google.com/group/nodejs?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nodejs" group.
> > To post to this group, send email to nod...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > nodejs+un...@googlegroups.com<nodejs%2Bunsu...@googlegroups.com>
> > .

mscdex

unread,
Oct 26, 2010, 6:28:08 PM10/26/10
to nodejs
On Oct 26, 5:33 pm, Dean Landolt <d...@deanlandolt.com> wrote:
> > prefixing with node is annoying.
>
> Amen. The exception would probably be libs that enhance core node features
> (like node-inotify). Just because you're targeting node today doesn't mean
> you won't be adding support for running in the browser tomorrow.

Eh... there's lots of modules that would never realistically have
support for running inside the browser, not just node-inotify.

Dean Landolt

unread,
Oct 26, 2010, 6:36:45 PM10/26/10
to nod...@googlegroups.com
True, but that doesn't mean they always have to be node-specific. 

Ryan Gahl

unread,
Oct 27, 2010, 9:53:50 AM10/27/10
to nod...@googlegroups.com
On Tue, Oct 26, 2010 at 5:13 PM, Corey Hart <corey...@gmail.com> wrote:
And if they manage to consolidate their plugin to a single script,
only 42 lines long. The module must be name "the-hoff"


Awesome. I see you've been reading the rules. That's rule 1a.

Also... I like semicolons;

Dean Landolt

unread,
Oct 27, 2010, 10:44:09 AM10/27/10
to nod...@googlegroups.com
This is a little more important than what the internals of your code looks like. The name of your packages and modules (at least the public ones) affects everyone using your code. But semicolons rock.

Joe Developer

unread,
Oct 27, 2010, 10:52:39 AM10/27/10
to nod...@googlegroups.com
I generally try to avoid hyphens in javascript, down the line it can break programatically working with them, see the CSS attributes problem as an example, ie marginTop vs margin-top. Underscores or dromedarCase seem just as functional with less issues.  

--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.

Dean Landolt

unread,
Oct 27, 2010, 11:59:42 AM10/27/10
to nod...@googlegroups.com
On Wed, Oct 27, 2010 at 10:52 AM, Joe Developer <joe.d.d...@gmail.com> wrote:
I generally try to avoid hyphens in javascript, down the line it can break programatically working with them, see the CSS attributes problem as an example, ie marginTop vs margin-top. Underscores or dromedarCase seem just as functional with less issues.  

If we're talking about module names they'll always be a string when you require them. Yes, it means you have to use something other than a hyphen for the symbol you assign them to, but that's no big deal. Perhaps underscores would be better but hyphens have sorta become defacto. The important thing is: don't use upper case letters...please...Windows is stoopid.

Joe Developer

unread,
Oct 27, 2010, 12:08:18 PM10/27/10
to nod...@googlegroups.com
Right, but a minor point is that someone, somewhen might want to programmatically but them into a js object, should they do a sanity check first? Sure! Should they run into a collision when module foo-bar and the internal transformation hits the existing fooBar? Doesn't need to happen. Anyway.  

Dean Landolt

unread,
Oct 27, 2010, 3:01:14 PM10/27/10
to nod...@googlegroups.com
On Wed, Oct 27, 2010 at 12:08 PM, Joe Developer <joe.d.d...@gmail.com> wrote:


On Wed, Oct 27, 2010 at 10:59 PM, Dean Landolt <de...@deanlandolt.com> wrote:


On Wed, Oct 27, 2010 at 10:52 AM, Joe Developer <joe.d.d...@gmail.com> wrote:
I generally try to avoid hyphens in javascript, down the line it can break programatically working with them, see the CSS attributes problem as an example, ie marginTop vs margin-top. Underscores or dromedarCase seem just as functional with less issues.  

If we're talking about module names they'll always be a string when you require them. Yes, it means you have to use something other than a hyphen for the symbol you assign them to, but that's no big deal. Perhaps underscores would be better but hyphens have sorta become defacto. The important thing is: don't use upper case letters...please...Windows is stoopid.
Right, but a minor point is that someone, somewhen might want to programmatically but them into a js object, should they do a sanity check first? Sure! Should they run into a collision when module foo-bar and the internal transformation hits the existing fooBar? Doesn't need to happen. Anyway.  


Huh? If they're doing it programmatically they're using the [] assignment form and it's a non-issue.

Joe Developer

unread,
Oct 27, 2010, 3:47:38 PM10/27/10
to nod...@googlegroups.com
It is a fair point that modules["module-name"] can be used. I guess I am just unjustifiably against hyphen/minuses when it comes to javascript.    

Pau

unread,
Oct 30, 2010, 6:57:49 AM10/30/10
to nodejs
+1 to david-hasselfhoff rule. It just makes sense.

On 27 oct, 21:47, Joe Developer <joe.d.develo...@gmail.com> wrote:
> On Thu, Oct 28, 2010 at 2:01 AM, Dean Landolt <d...@deanlandolt.com> wrote:
>
> > On Wed, Oct 27, 2010 at 12:08 PM, Joe Developer <joe.d.develo...@gmail.com
> > > wrote:
> > nodejs+un...@googlegroups.com<nodejs%2Bunsu...@googlegroups.com>
> > .

Julien Polo

unread,
Nov 1, 2010, 5:56:01 AM11/1/10
to nodejs
So ok there are no conventions at the moment... But beside the david-
hasselhoff module or the chuck_norris_round_house_kick, maybe it would
be interesting to ask the main contributors to define those
conventions if they think too it is a good thing? Conventions are
never mandatory developers have always the choice not to follow them,
but it is better for collaboration between projects...

For example, I totally agree with Dominic Tarr, others are against
hyphens and I respect their choices. My point is that conventions
should be defined and explicitly written on the node or npm website...
Reply all
Reply to author
Forward
0 new messages