Besides it is proven to be capable of doing great things (Google Apps) it was great help to us too. It provided us with large number of widgets, cross browser support (including mobile devices) and dedicated tools such as Closure Compiler and templating engine.
Take advantage of OO design and pair it with the power of this scripting language. Application shouldn’t be just a set of scripts that run as they are loaded into browser.
Design your client app with clean separation of concerns between modules and classes. Design it to be multi tier application. It is more complicated to do, but it will help maintainability and boost understandability.
- Use packages and namespaces as source organization
- Use “One class, one file” rule
This is the easiest way to organize your code. You will have a bunch of files, that’s true, but you will know exactly what every file contains and what every class does (with assumption you were giving classes logical names). Adding to the UberCustomer example from the above, file containing the class should be called UberCustomer.js. I bet this sounds familiar.
- Separate component communication by using event bus
Don’t let you code become tangled cause every class can directly call any other class’s functions. Make different parts of the app communicate with each other using messages, i.e. events. Ones should fire those messages, others should listen. Just like in real communication – if everybody talk at the same time, nothing can be heard.
- Document, document, document
If infrastructure exists, create project wiki pages – this will help your team in discussing problems and solutions. When solution is implemented, write an article about how it’s done – great help when tring to remember what was done or when new team member is getting introduces to the project.
If we take a minute and think a bit about what is said, we could agree that it is nothing revolutionary. Every application, written in no matter which language, should be developed having in mind good organization, easy maintenance and steep learning curve.