Highlight

2014-10-03

Useful comments

While the comments in my Assembly post were useful to beginners, experts who can read the code might find them annoying. Here's an example of helpful comments for experienced programmers:

function delete_month(id, index){
 load_branch(id)
 $(".row[id^="+id+"] .cell:nth-child("+(index+1)+")").each(function(i,e){
  if(i==0 && e.className.indexOf("draggable")<0) return  // only change sandbox budget.
  $(this).nextAll().each(function(i,e){
   this.style.left = (parseInt(this.style.left)-mw)+"px"
   cellBlur(this)  // update availability
  }).addClass("changed")
  $(this).prevAll().addClass("changed")  // needed in case there is no next cell.
  $(this).remove()
 })
 //updateTotals()  // too slow here
 btnSave.value = "Save*"
 setBusy(0)
}
Note that i'm describing WHY the code is there, not HOW it works (which should be obvious to any decent JavaScript coder, who also should have an editor capable of wrapping lines to their preferred width).

No comments:

Post a Comment