yunap / traceit

jQuery plugin based on raphael.js that lets you dynamically trace page elements. Now also available as AngularJs directive:
https://github.com/yunap/angular-traceit
72 stars 5 forks source link

Formatting needs some tender love #1

Closed ghost closed 10 years ago

ghost commented 10 years ago

To improve readablity and facilitate contributions code needs to be cleaned up. Unified coding style also helps, choose one and stick to it. Examples:

Space before argument list in function declaration:

function someFunction () {}

var anotherFunction = function () {};

No space between function name when invoking:

var foo = barBaz();

Conditionals and cycles generally need spaces for readability:

if (condition) {
    // stuff
} else {
    // antistuff
}

Commented code generally concidered unnecessary.

ghost commented 10 years ago

Tip: try http://jsbeautifier.org/ and/or JSLint.

yunap commented 10 years ago

I put the code through http://jsbeautifier.org/ and, in the name of uniformity, changed variable names and function names to camelCase. Personally I prefer snake_case. But ... the main "disadvantage" of snake_case is that we are using 3rd party libraries which have functions and variables that are in camelCase. Then we have to use two different case-strategies, which probably can be a bit confusing.

ghost commented 10 years ago

Exaclty. Me, I prefer snake_case myself, but all the built-in names in JS and most names in popular libs are camelCase, so we should bite the bullet, and man up, and camelCase ourselves.

ghost commented 10 years ago

Friendly tip: your JS will benefit significantly from "JavaScript: the good parts." You don't have to follow it word by word, of course, but it improves style and readability.

yunap commented 10 years ago

Hi Eugene! I actually read it. Are we still talking formatting or do you see something in traceit.js that's not a good JS code practice?

thank you! Yuna

On Thursday, May 29, 2014 12:12 AM, Eugene Chernikov notifications@github.com wrote:

Friendly tip: your JS will benefit significantly from "JavaScript: the good parts." You don't have to follow it word by word, of course, but it improves style and readability. — Reply to this email directly or view it on GitHub.

ghost commented 10 years ago

Code (imho) needs more comments explaining algorythms and less two-letter variable names for code self-documenting. The rest of your code is reasonably good, no horrible antipatterns.