Arieh.co.il

Decoupling Js Code

This series is about somewhat advanced JS techniques. If you are new to JS, I suggest you first read my JS guide.

I've recently been putting a lot of effort into adding more and more decoupling into my code principles. I find myself trying harder and harder to make each piece of my code as independent of its context as possible.

There are many reasons for doing this - for one, it makes development much easier. At its best, I can develop each part of my application without worrying about the rest. It also makes it much easier to write tests for my code, although I'm ashamed to admit that the amount of time I spend making my code (almost every piece of code) testable is nowhere close to how much time I spend writing tests (almost none at all). So after a few conversations on the subject, I thought I'll write it up. Most of it verges on trivial, but I hope that the sum of it will have some value. This will be a short series of articles, and I in no way persume to call it comprehensive.

I will try to keep this about JS itself, and not about one library or another. If I do start writing on Mootools (my love), I hope you'll be able to see that it's just an example of a point I'm trying to make.

Table of Contents

  1. Classes
  2. Lambdas, Closures and Scope Resolution
  3. Events
JavaScript Reference, JavaScript Guide, JavaScript API, JS API, JS Guide, JS Reference, Learn JS, JS Documentation