Backbone.js 菜鸟被相互矛盾的教程弄糊涂了 [英] backbone.js noob confused by conflicting tutorials

查看:18
本文介绍了Backbone.js 菜鸟被相互矛盾的教程弄糊涂了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是backbone.js 的新手,正在学习一些教程.我发现了一些看起来不错的方法,但它们的实施方式存在一些不一致之处,因此我正在寻找有关最佳做法的一些指导.

I'm new to backbone.js and am working my way through some tutorials. I've found a couple that seem good, but there are some inconsistencies in how they implement so I'm looking for a little guidance on best practices.

以下是我正在学习的教程:

Here are the tutorials I'm learning from:

我的问题是:

  1. 第一个 tut 使用了 Backbone.Controller 而不是 Backbone.Collection.第二个则相反.MVC 上的主干中的C"的最佳实践是什么?
  2. 第一个 tut 在模型中定义 url,而第二个在集合中定义它.哪种做法更好?
  3. 第二个 tut 使用了 Backbone.Router,而第一个没有.哪个是最佳做法?

或者,如果有人可以建议遵循最佳实践的更好的介绍教程,我很乐意从那里学习.不幸的是,由于这两者之间的不一致,我担心我可能会从一开始就养成一些坏习惯.

Alternatively if someone can suggest a better intro tutorial that follows best practices I'd be happy to learn from there. Unfortunately because of the inconsistencies between these two, I'm concerned I might be learning some bad habits out of the gate.

提前致谢.

推荐答案

Backbone.Controller 被 重命名 Backbone.Router 去年.我猜你正在阅读旧教程.

Backbone.Controller was renamed to Backbone.Router last year. I guess you were reading an old tutorial.

BackboneTutorials.com 是一个不错的入门教程.

BackboneTutorials.com is a decent tutorial for getting started.

在学习的过程中构建一个小型应用程序,您就会知道 Backbone 为您做什么.

Build a small app as you learn and you'll know what Backbone does for you.

学习 Backbone 的最佳方式是阅读带注释的源代码.每一行都有注释和解释.

The best way to learn Backbone is to go through the annotated source code. Each and every line is commented and explained.

在构建应用程序时使用开发版本而不是缩小版本.这有助于调试.

Use the dev version instead of the minified version when building your app. This helps in debugging.

如果您喜欢读书,请查看 Addy Osmani 的 Backbone Fundamentals,这是一个免费的电子版书.这本书很棒,但很冗长.可以作为参考.

If you are into reading books, check out Addy Osmani's Backbone Fundamentals, a free e-book. The book is awesome, but quite verbose. You can use it as a reference.

参见 这个问题 以获取最终资源列表;

See this question on Quora for the definitive list of resources;

不要太担心什么是V",什么是C",以及主干在 MVC 上的旋转.该框架在分离与服务器交互的代码和执行核心客户端逻辑的代码方面做得非常出色.DOM 元素的模板化和更新由您来完成.从这个意义上说,它非常简约.Backbone 提供了事件,使不同部分相互交互.

Don't worry too much about what's 'V' and what's 'C' and backbone's spin on MVC. The framework does an excellent job of separating code that interacts with the server and the code that performs the core client logic. Templating and updation of DOM Elements is left to you. It's pretty minimalistic in that sense. Backbone provides Events that make the different parts interact with each other.

这篇关于Backbone.js 菜鸟被相互矛盾的教程弄糊涂了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆