You are on page 1of 5

Making a modular and organized javascript

heavy application

By using a modularity design is not directory structure, its


architecture. Any developer can manage the application from the top
level folder and easily gain insight into what the application does.
Objects in the same folder now express their relationship and their
dependencies to others. For instance, understanding how the todo
process works by browsing the files in that folder.

Keep the routers simple


Backbone.Router provides methods for routing client-side pages,
and connecting them to actions and events. The design builds the
structured class approach and class inheritance.

Implement inheritance pattern using Backbone.Router as below:


BaseRouter.js

Todo.Router is inherited by BaseRouter

Keep the model pattern simplicity


Business logic belongs to models

Data processing should always be kept in models, that way they can
easily be shared between collections and other services.

Any event that is triggered on a model in a collection will also be


triggered on the collection directly, for convenience. This allows you
to listen for changes to specific attributes in any model in a
collection.

Store Templates in Their Own File


Splitting the templates into the small pieces to improve the
performance when rendering the DOM.

Integrating the partials into the view


A better pattern would be to take care of these in the views parent

We can also create some functions to support the business logic for
this view as below:

Automate your workflow


Backbone is growing fast. Each month new tools are released.
Use them to build your own boilerplate and use that for your
projects
Grunt is used to build, preview and test your project.

You might also like