BackboneJS v/s CanJS which one is better? [closed] - backbone.js

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I'm confused between the two choice which one to use BackboneJS/CanJS for my next project. Can anyone suggest which one is better ?

They have many similarities and differences, here are some:
Similarities
They both have models that can be observed, they use similar patterns for setting attributes
CanJS has Controls which in are quite similar to Views in Backbone, you listen to events in similar way in both
They are both small and very flexible
Routing in quite similar in both, Backbone has a special Router object while in CanJS you do the routing inside a Control class, but they are quite similar
I found that many of the patterns of doing things in Backbone are translatable to CanJS
Differences:
Backbone has a huge community, tons of plug-ins for doing about anything
You are likely to find more documentation and help when using Backbone
Backbone doesn't have a prescribed way of doing things e.g. rendering views. So this can be good or bad, depending on how you see it. Many time it leads to many projects doing things totally different when using Backbone.
Backbone doesn't implement view rendering or two way bindings, is up to you to implement that somehow
CanJS has reactive views using EJS or Mustache, so there is a defined way of doing this, it also has two way bindings
CanJS has components
CanJS is quite good at avoiding memory leaks, if you follow certain patterns, for example if you are listening for a window resize event inside a control, when you remove the control from the DOM CanJS will also remove the listeners automatically, in Backbone you have to do more manual work

Related

When should you use a front-end framework like Angular or React, and when just use plain HTML/CSS/JS? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I know that for a simple static website, using plain HTML.. is the easiest and quickest way. But, what are some use cases between the two options? Is using a framework mostly the best solution?
You can basically see frameworks as pre-written structures for your App.
In other words, frameworks are meant to help you building applications quicker by addressing common development problems.
So, going back to your question, there are not really times where you would prefer vanilla javascript over frontend frameworks due to the incapacity of scaling well, which could result in inscrutable and unmaintainable spaghetti code.
Other bit you would want to consider about frameworks, is their high performance obtained thanks to their virtual DOM (abstract map of the real DOM), which helps handling events to update parts of the App without the need of re-rendering it.
On the other hand, I would suggest to go with a static website using pure HTML and Vanilla JS, only if learning / instructing someone, or if building something really really simple (but rest assure 99% of your commercial websites may suit better under a framework rather than without).
If you want to read more about it, I would suggest the following articles:
https://stackoverflow.blog/2020/02/03/is-it-time-for-a-front-end-framework/
https://gomakethings.com/why-do-people-choose-frameworks-over-vanilla-js/
https://www.freecodecamp.org/news/do-we-still-need-javascript-frameworks-42576735949b/

Are there any features that ReactJS possess, while AngularJS lacks? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I was playing with ReactJS for a bit, and given a bit of prior exposure to AngularJS, and the way things are done in the latter, I had a hard time to get used to the syntax and the 'flow' of React.
So I had the above-mentioned question, plus: are there scenarios when ReactJS should be preferred to AngularJS?
Could anyone point out what can be done [easier/better/more efficiently] in React rather than in Angular, and other way around.
It's actually the opposite. Angular has a lot of features, apis, configuration options, etc. React tries to be much simpler and let you choose how your application is structured. Controllers, directives, and templates are reduced to just components. Services are just plain JavaScript, there's nothing React specific about it. Things like $q and $timeout don't exist because there's no digress (use anything you like for those).
You use React in your application, vs making your application in angular.
ReactJS uses the concept of virtual DOM which speeds up the rendering of the app.
Watch Pete Hunt's excellent video on Virtual Dom here:
https://www.youtube.com/watch?v=-DX3vJiqxm4
The syntax might be very unconventional but the same thing can be said about Angular's concept of Directives, services, controllers, etc. It just takes time to get used to, but once you feel comfortable, you'll find that thinking in ReactJS really makes sense.

AngularJS best approach: data driven or event driven? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
AngularJS is famous of the '3d': data binding, dependency injection and directives. As data binding is such a nature of angularJS application, I always assume data-driven is the best approach when making decision on how the app works.
For example, if I want to respond to some property updates, I will $watch on that property and write call back functions for it. And if I can use angularJS properly, there is no $apply required and the two way data binding will automatically do the magic with the great digest cycles.
However, in jQuery or many other JavaScript libraries, event-driven seems to be so common that people always think this is how client side should work. Event-driven approach in angularJS, on the other hand, means I need to $emit or $broadcast events across directives/controllers to throw events here and there. This is somehow different to the data-driven approach.
My idea is event-driven makes the whole application hard to debug, understand and maintain. The only reason I use it is because it's easy to pass data across scopes, when the nested scopes themselves are too complicated to do so.
Any idea on this? When should we stick to data-driven and when should we use event driven? What is the best approach in general?

Is it better to make Backbone.js applications single page applications? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Since Backbone's Router only work with "#", it means that it should be all in the same page. Should a BB application be only in one page and have only 1 Router?
One of the many nice things about Backbone is that it is very unopinionated about how you work with it. For example, if you just want to use views, then you can do that, and if you want to just use models, you can do that as well.
A Backbone application can be a single-page application, and it certainly provides a lot of functionality to make that easier if that is your goal, but it doesn't have to be. There is absolutely nothing wrong with explicitly calling your views by hand instead of using a router.
To answer the second part of your question... No, you can have as many routers as you like. However, I'd say a large portion of Backbone apps out there make do with just one. I am working on a Backbone app that has over a hundred different views, and I've never run into an issue where I'd have to introduce a secondary router.
Finally, a bit of a correction on your end; The Router object actually doesn't enforce the "#" anymore as long as your browser has pushState functionality. Older browsers (mainly IE) will fallback to the hashtag approach if necessary.
Hope this helps!

What design patterns have you used in your WPF efforts and which do you like? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I have been looking at the Model-View-ViewModel pattern that is suggested by several people out there (especially John Gossman, take a look at this post and this podcast), but what other patterns (if any) have people used and liked ... and where do they add value?
I have also stumbled across:
Model-View-ViewModel
Presentation Model
DataModel-View-ViewModel
Patterns in Prism (now known as the Composite Application Guidance for WPF)
I would love an active discussion on these above and those I may not have discovered yet.
Another pattern that we have used and loved is the Attached Behavior pattern ... using the extensibility mechanism of attached properties in WPF. There are quite a few posts out there on this useful pattern as well.
http://blogs.msdn.com/johngossman/archive/2008/05/16/attachedbehavior-pattern-sample.aspx
http://blogs.msdn.com/johngossman/archive/2008/05/07/the-attached-behavior-pattern.aspx
http://blogs.msdn.com/dancre/archive/2006/03/04/543854.aspx
http://www.codeproject.com/KB/WPF/AttachedBehaviors.aspx
I have been using a variation of the Model-View-Presenter pattern. It has served our purposes pretty well developing various UIs. It is not perfect but it gets the job done well. One of the issues I've had is that I am never satisfied with multi-threaded scenarios. We've recently been making many of our presenters multi-threaded. Since these worker threads, in the end, update the UI, we have had to dispatch actions to the UI through the View's dispatcher. Code was becoming really verbose if every View property checked the dispatcher so because of time constraints, we ended up exposing the View's dispatcher to the Presenter. Not the greatest move if you ask me...
We are using a modular UI framework similar to CAB and Prism, so a lot of those patterns apply to us as well.
I am also a big fan of Commands in WPF. I haven't been able to play around with Prism's DelegateCommand and CompositeCommand yet, but they sound really nice.

Resources