Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migration from Backbone to AngularJS - how difficult it is?

I'm developing a big project in Backbone (around 8000 lines of javascript, excluding external libraries) and I'm considering a migration to AngularJS.

Currently I have a lot of code that handles DOM changes, binding and unbinding of events. I'm using Mustache for template rendering. Most data is loaded with AJAX, and stored in Backbone models, some of which use BackboneRelational. I'm using about 10 little jQuery plugins to do fancy UI stuff.

I'm determined to do this migration, however I'm worried about my deadlines. So the questions are:

  1. How long can it take to rewrite it using AngularJS? Maybe someone can share his experience.
  2. Is it possible to start using Angular right now, and implement new functionalities with it, without causing headaches when we need to interact with the Backbone part?
  3. If I'll decide to do this refactoring after the deadline, what practices would you recommend to make the code easier to migrate?
like image 807
mik01aj Avatar asked Apr 16 '13 14:04

mik01aj


1 Answers

I ported a large 5k+ lines of BB code to Angular. I did this port when I was first starting with Angular and if I remember right, I did it over a weekend and then 3 days. So it was done in 5 days approx. You have to note that I wrote the whole BB application ( all of the 5k lines as well .. ) so it was easier for me to port.

You could perhaps mix BB and Angular initially ( develop new parts in Angular and slowly port BB parts over.. ) but I would suggest that if you can, then do the porting of the complete app first.

As a general rule, all your Backbone Models and Collections should go into services ( of the same name perhaps ? ) . Porting html and Mustache templates should be a piece of cake. The part that would be slightly tricky is your jquery plugins. But if they are simple ones then you will be able to use the angular-ui jquery passthrough ( http://angular-ui.github.io/ ).

like image 169
ganaraj Avatar answered Sep 28 '22 01:09

ganaraj