Skip to main content
1 of 2
palacsint
  • 29.9k
  • 9
  • 81
  • 156

A few minor notes:

  1. Comments like this:
// Creates an empty template with all present data, in order.
$.each(tplArray, function(i, elm){

and this:

//Populates the template with data
$.each(data, function(i, item){

could be great function names. It would also increase the abstraction level of the code which helps maintainers with a quick overview about what the code does (without the details). They still can check the details inside the functions if they're interested in. It usually requires less code to understand (so it's faster and easier), especially if they want to modify only a small part of it.

(Clean Code by Robert C. Martin, Don’t Use a Comment When You Can Use a Function or a Variable, p67.)

1.

var scope     = this;
var parent    = this.element;
var tpl       = "";
var tplArray  = scope.options.template.replace(/[\s,]+/g, ',').split(',');

I've found this kind of indentation hard to maintain. If you have a new variable with a longer name you have to modify several other lines too to keep it nice. It could also cause unnecessary patch/merge conflicts.

  1. Comments on the closing curly braces are unnecessary and disturbing. Modern IDEs and editors could show blocks.
}; //findLinks

“// …” comments at end of code block after } - good or bad?

palacsint
  • 29.9k
  • 9
  • 81
  • 156