code | 3-11-2011
Multiple Files that compress down
Comments are helpful not only to help to debug code later on, but also to help you think through what the code is actually doing. I often write comments for my code before I write it in order to think through what I intend for it to do. Another great thing about comments is that you can use an application like JSDoc-Toolkit to extract the comments in the files into documentation.
Separate code into Model, View and Controller
Don't let your modules talk to each other
I try to break my code into small modules that absolutely never call each other. In practice, the modules should never even be aware of each others existence. That way if something changes in one module, it will never effect the other modules. When a module does make a change that everyone should be aware of, it announces it to the application. The modules that are listening for that particular event react to it. Again, modules should never be aware of each other.