Ram
Ram

Reputation: 127

Best approach for implementing Backbone js and jQuery

Can some one help me to find the best approach? Its is documentcloud.

References between Models and Views can be handled several ways.

  1. Direct pointers, where views correspond 1:1 with models (model.view and view.model).
  2. Intermediate "controller" objects that orchestrate the creation and organization of views into a hierarchy.
  3. Evented approach, which always fire events instead of calling methods directly.

Thanks!

Upvotes: 2

Views: 133

Answers (1)

Benny Johansson
Benny Johansson

Reputation: 771

I do believe that 3 is best practice in this case. The observer pattern or subscriber/publisher patterns promotes loose coupling between your objects. This means that your objects has no knowledge about each others implementation details. The benefit of this is that you can more easily change one of your objects later on, for example a method name, without risking that your application breaks somewhere else. This is great for maintainability.

Also, the observer pattern (3) promotes code reuse since you can more easily replace or extend objects in your application. Relying on a specific structure or hierarchy of your application seems like it could counteract reuse of your code within other projects for example.

Upvotes: 6

Related Questions