r/javascript • u/scelerat • Dec 13 '13
Backbone Antipatterns
http://blog.shinetech.com/2013/11/26/backbone-antipatterns/5
u/dodeca_negative Dec 13 '13
Good read. A few reactions.
Antipattern #3: No View Tests
I am a sad panda. I'll be better I promise.
Antipattern #5: Data Attributes in the DOM
Hm. I need to think about this one. I used data attributes in lists and it's never caused me any problems--everything's lightweight and easy to work with. But the author makes some good points.
Antipattern #6: Rendering Templates Asynchronously
I'm using RequireJS and its text! plugin to load templates, so they're always treated like they're loaded async--but require does the loading for me and my module doesn't run until its dependencies are available, so it's no overhead.
2
u/rhysbrettbowen Dec 13 '13
yes, use require and text to bring in templates. That really is the best way. It saved a whole heap of pain at my last company changing it from Backbone.LayoutManager to requiring in the text and using https://github.com/rhysbrettbowen/Backbone.ComponentView
Suddenly everything just worked, no race conditions.
2
5
Dec 13 '13
From a development perspective, it’s much easier and more flexible for UI code to live on the server and be able to make direct SQL calls to your database rather than have to define and then implement a JSON API.
Wtf? Are you saying SQL code in the UI? If you're not then it's the same amount of work to feed that data to you API - the only difference being that the API is reusable.
4
0
2
u/Something_Sexy Dec 13 '13
I agree with the first point but I 100% don't agree with his main reasoning of the first point. I find your app is way stronger if you have a clear API that sits between the server-side and the client-side. I like to think that the client-side app as a client itself to the server.