Refactoring JavaScript

The rise of Ajax and Rich Web Applications, plus the success of dynamic languages, has caused people to revisit the JavaScript language. Now that we take JavaScript seriously as a language, it is time to get serious about the quality of JavaScript code, through refactoring. In this talk, we will approach refactoring JavaScript in three phases:

  • Test first, then refactor. Bring JavaScript code under test, so that you can refactor with confidence.
  • Refactoring 101. Explore some important refactorings: composed method, extract method, introduce named parameter, and extract object
  • Common problems. Work through three problems endemic to legacy JavaScript code: making JavaScript unobtrusive, refactoring to prototype-based inheritance, and refactoring to functional style.