chevah / geck

Chevah Garden Of Eden Creation Kit
http://geck.chevah.com/
0 stars 1 forks source link

Update JS styleguide. #2

Closed adiroiban closed 11 years ago

adiroiban commented 11 years ago

Problem description

The JS styleguide is still young and it requires expansion, at least for comments conventions.

Changes description

Added guides for comments and global variables.

How to try and test the changes

reviewers @alibotean @bnickname

I have also updated the website http://styleguide.chevah.com/javascript.html

Check that changes make sense and you are happy with them.

Please use this review to add any other comment related to JS styleguide.

Note that styleguide , even if is part of Chevah project, it is released as an independent open project. Tickets are not listed in our internal Trac. In this way other teams can check and reuse it.

adiroiban commented 11 years ago

needs-review

bnickname commented 11 years ago

I like to suggest to use 4 space as indentation like it used in python. With 2 spaces the code seems to be too condensed. In rest the changes are good. needs-changes

adiroiban commented 11 years ago

I would also like to us 4 spaces for JS but for now I failed to gather enough reasons to switch to 4 spaces.

The initial code was written with 4 spaces and we now have a mix of indentation.

My initial reaction to 2 spaces indentation was also that code is to condensed ... but after a while I got used to it.


I first start considering 2 spaces after looking to other JS style guides. Google styleguide

It looks like many other projects are using 2 spaces, AngularJS, EmberJS, Bootstrap, Backbone, Zurb Foundation, NodeJS (which is not a browser project so no DOM).

Jquery uses TABs :) http://contribute.jquery.org/style-guide/js/

Now idiomatic.js uses 2 spaces https://github.com/rwldrn/idiomatic.js while JS Garden uses 4 spaces http://bonsaiden.github.io/JavaScript-Garden/ Douglas Crockford uses 4 spaces in his code.


I don't have a strong feeling for 2 or 4 spaces so I would like to get some feedback from Adi Libotean.

Thanks for the feedback.


I have added a few more notes about code organization. Please check the last commit.

needs-review

bnickname commented 11 years ago

Thanks for the changes. The changes look good. approved-at 9c72617

alibotean commented 11 years ago

Looks good to me.

I don't have a strong opinion about 2 or 4 spaces indentation. Although I can see a traffic performance reason for using 2 spaces instead of 4 when having a lot of JS code I think it does not apply to us.

Either way is fine for me.

approved-at 9c72617

adiroiban commented 11 years ago

Thanks for the review.

OK. Let' try to use 4 spaces and if code starts to go over 78 characters we can reconsider use 2 spaces.

There is no performance issue in using 2 vs 4 spaces. For performance we can always use HTML/JS/CSS minifiers.

Cheers