javascript 学习backbone.js 的最佳方法是什么?还有其他选择吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6024826/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the best way to learn backbone.js? Any other alternatives?
提问by egervari
I'm just starting to get into backbone.js. It looks like it's pretty involved and won't be something you can just look at one example and say, "Well, that's easy!" and start being productive with it. It does look good though.
我刚刚开始接触backbone.js。看起来它非常复杂,不会是你可以只看一个例子然后说,“嗯,这很容易!” 并开始高效地使用它。不过看起来确实不错。
The documentation is okay, but I find myself not understanding the 'big picture' very well, and how all of these components work together. The way events are bound and rendered in the various views actually seems like a lot of entanglements. I understand the need for separation of concerns, but I am actually wondering if it's just a tad over-engineered.
文档还可以,但我发现自己并没有很好地理解“大局”,以及所有这些组件如何协同工作。在各种视图中绑定和呈现事件的方式实际上看起来有很多纠葛。我理解关注点分离的必要性,但我实际上想知道它是否只是有点过度设计。
Essentially... I won't be able to be immediately productive with backbone.js. There is going to be a a day or two learning curve I think.
基本上...我将无法立即使用backbone.js 提高工作效率。我认为会有一两天的学习曲线。
What is the best way to get into backbone.js? Just keep chugging along, or are there some larger sample applications to download somewhere to look at?
进入backbone.js 的最佳方式是什么?继续努力,还是有一些更大的示例应用程序可以下载到某个地方查看?
Are there better alternatives that might be easier to learn and offer the same sort of benefits? For me, productivity and intuitiveness are pretty important. I sort of feel like the way backbone.js works is a little foreign. That could just be me.
是否有更好的替代方案,可能更容易学习并提供同样的好处?对我来说,生产力和直觉非常重要。我觉得backbone.js 的工作方式有点陌生。那可能只是我。
Put another way, would it maybe be better to develop my application without a library like backbone and sort of organically create a framework like backbone.js but more like something that is intuitive to me and something more inline with the resultant code base?
换句话说,在没有像backbone这样的库的情况下开发我的应用程序并有机地创建一个像backbone.js这样的框架,但更像是对我来说更直观的东西并且更符合结果代码库的东西会更好吗?
I've been trying to get simple examples to work with my own code, and I get no Javascript errors... but it doesn't work. There's a good chance that "one minor thing" is wrong... but I'm beginning to feel that debugging my backbone applications might be a problem... so perhaps organically growing my own might actually be a better option for my own sanity. Debugging in the dark is a real productivity killer... and honestly, I'd rather do my own framework and write my own code if it spares me hours of endless debugging.
我一直在尝试使用简单的示例来处理我自己的代码,但我没有遇到任何 Javascript 错误……但它不起作用。“一件小事”很可能是错误的……但我开始觉得调试我的主干应用程序可能是一个问题……所以也许有机地发展我自己的应用程序实际上可能是我自己理智的更好选择. 在黑暗中调试是一个真正的生产力杀手……老实说,如果能让我免去数小时无休止的调试,我宁愿做自己的框架并编写自己的代码。
I don't know what to do - hence why I am asking.
我不知道该怎么办-因此我要问。
采纳答案by onteria_
As with learning a lot of programming related things, my advice would be:
与学习很多编程相关的东西一样,我的建议是:
- Pick a task you think is suitable for what you're working with
- Attempt to execute that task
- If you find you're stuck, show the code you have and explain what you think should be happening. Make sure you check documentation to verify your functions work as you expect them to.
- As you progress, people will also show you more standard and efficient ways to do things
- Keep doing this until you become more familiar with how things work
- Now, look over documentation in depth to help fully master how it works as a whole, continuing to ask questions
- Pretty soon you'll be answering questions more than asking them
- 选择您认为适合您工作的任务
- 尝试执行该任务
- 如果您发现自己卡住了,请展示您拥有的代码并解释您认为应该发生的事情。确保您检查文档以验证您的功能是否按预期工作。
- 随着你的进步,人们也会向你展示更标准、更高效的做事方式
- 继续这样做,直到您更加熟悉事物的运作方式
- 现在,深入查看文档以帮助完全掌握它的整体工作方式,继续提问
- 很快你就会回答问题而不是问问题
回答by codef0rmer
I've come across the awesome book, Developing Backbone.js Applicationsby Addy Osmani. Addy has clearly explained MVC, writing modular code, testing JS code using jasmine and many more in detail.
我看到了 Addy Osmani 写的很棒的书《开发 Backbone.js 应用程序》。Addy 已经清楚地解释了 MVC、编写模块化代码、使用 jasmine 测试 JS 代码等等。
EDIT:
编辑:
There is an open source version of the same bookas well.
也有同一本书的开源版本。
回答by DMin
To partly answer your question. I had the same issue and was about to give up too. None of the examples worked, I later figured you are supposed to put all your backbone javascript at the end of your document, so that your page has loaded and backbone can work with it.
部分回答你的问题。我有同样的问题,也即将放弃。没有一个例子工作,我后来想你应该把你所有的主干javascript放在你的文档的末尾,这样你的页面已经加载并且主干可以使用它。
Underscore, Then Backbone
I think the best way to go about it is, first go through the underscore.js documentation once. You will get a feel of what it is about, backbone.js documentation does not explain underscore stuff. So, you are bound to get confused about what it is. But once you know what underscore is about then backbone.js will start to make more sense.
Underscore, Then Backbone
我认为最好的方法是,首先浏览 underscore.js 文档一次。你会感觉到它是关于什么的,backbone.js 文档没有解释下划线的东西。所以,你一定会对它是什么感到困惑。但是一旦你知道下划线是什么,backbone.js 就会开始变得更有意义。
Also after teaching backbone to a couple of my colleagues at work, I have realized this.
There are 3 parts to learning Backbone.js -- Its my subjective opinion :
在给我的几个同事教过骨干后,我也意识到了这一点。
学习 Backbone.js 有 3 个部分——这是我的主观意见:
1)You should know JavaScript (not just jquery use, but, things like, what is an object, how functions work, what is context, how it works in javascript -- if you dont know javascript well, you'll be somewhat lost.
2)There are things that you have to just assume and learn by heart -- this is how the structures work, this is how the basic app is setup. Somethings in the beginning will not make sense, just learn them by-heart.
3)Other things you will have to understand, what is actually going on.
1)你应该知道 JavaScript(不仅仅是 jquery 的使用,还有诸如什么是对象、函数如何工作、什么是上下文、它在 javascript 中如何工作——如果你不太了解 javascript,你会有点迷茫.
2)有些事情你必须假设并记住——这就是结构的工作原理,这就是基本应用程序的设置方式。一开始的东西是没有意义的,只要把它们背下来就行了。
3)其他你必须了解的事情,实际发生了什么。
It takes time to figure out which one is 2 and which one is 3 and this is when someone who has worked on the framework teaches you, you'll pickup very easily. Again its my subjective opinion.
弄清楚哪个是 2 哪个是 3 需要时间,而当有人在框架上工作过教你时,你会很容易上手。再次是我的主观意见。
If you are looking at getting something up and working in very little time with a lesser learning curve try Knockout JSyou'll pick it up in no time.
如果您希望在很短的时间内完成一些工作,并且学习曲线较短,请尝试使用 Knockout JS,您很快就会学会它。
回答by Attila Gy?rffy
I always find myself learning new things a lot easier through screencasts. It might be the visual recognition, not sure. Anyway, I found the relevant Peepcode screencaststo be pretty helpful in understanding the basics and the ideology of Backbone.js. Hope they could help you too.
我总是发现自己通过截屏视频更容易学习新事物。可能是视觉识别,不确定。无论如何,我发现相关的 Peepcode 截屏视频对于理解 Backbone.js 的基础知识和意识形态非常有帮助。希望他们也能帮到你。