Skip to content

Coding Style and Best Practices

mnjuhn edited this page Jan 14, 2013 · 1 revision

Coffee Script

For this project, we're following:

https://github.com/polarmobile/coffeescript-style-guide

Backbone

Backbone.js is an event based collection/model/view javascript library used to facilitate syncing of server-side resources to it's models through a RESTful design. Changes to the models should trigger events with are then handled in it's views to display these changes via underscore.js templates or save them via a RESTful call to the server.

Here is a list of some of the best practices:

  • Views should be bound to change events in models and reset/add/remove events in collections.
  • Use the this.$el attribute to reference the parent DOM element of a particular view - only works after view has been placed.
  • Syncing models/collections should be done as individual REST calls, however this creates a dilemma as how to save multiple changes in the models and collections on a save event. Either these model changes all have to be cached to map to particular REST API call or we trigger them as changes happen (which means there is no save button).

http://jonathanotto.com/blog/backbone_js_for_the_everyman.html

Clone this wiki locally