rezoner / playground

Playground.js is a framework for your javascript based games. It gives you out-of-box access to essentials like mouse, keyboard, sound and well designed architecture that you can expand to your needs.
MIT License
466 stars 50 forks source link

Perfection kills #5

Closed rezoner closed 9 years ago

rezoner commented 9 years ago

Consider a plugin for a library named playground.

Library namespace is var PLAYGROUND = { }

Plugin is represented by a constructor PLAYGROUND.SoundOnDemand = function() { }

reasonable permutations

playground.SoundOnDemand.js
playground.soundOnDemand.js
playground.soundondemand.js
playground.sound-on-demand.js

What would you pick - and WHY?

nknauth commented 9 years ago

I'm accustomed to playground.soundOnDemand.js because that's Impact JS's convention, but the AirBnB JS Style Guide makes a good point:

If your file exports a single class, your filename should be exactly the name of the class.

// file contents
class CheckBox {
  // ...
}
module.exports = CheckBox;

// in some other file
// bad
var CheckBox = require('./checkBox');

// bad
var CheckBox = require('./check_box');

// good
var CheckBox = require('./CheckBox');

If you want to follow that convention, it seems that playground.SoundOnDemand.js would be the way to go.

rezoner commented 9 years ago

Thanks @nknauth - I am going with AirBnB style guide - kinda...

PLAYGROUND.whateverYouPutThere

dictates:

playground.whateverYouPutThere.js