How I Navigated to AngularJS

This article is about the process I’ve gone through of selecting AngularjS as my MV* JavaScript framework of choice. I will discuss the evolution I went through from learning jQuery, Knockout, Backbone.js, and eventually settling on AngularJS.

I’ve been programming in JavaScript since the late 90′s. JavaScript is not going anywhere. JavaScript is very popular today, and I believe it will only get more popular. For programming a browser, JavaScript is the least common denominator. This is the only language that all Browsers support. But, JavaScript has many pitfalls; just read the book JavaScript: The Good Parts by Douglas Crockford. In the early years, I used JavaScript mostly for validation and simple DOM manipulation. Writing different code for each browser sucked. Back in the early years JavaScript seemed like a toy, there weren’t many best practices and the expectations of what could be accomplished with JavaScript was limited.

In 2009 I started using JQuery. This is a great library. JQuery abstracted much of the DOM manipulation away from the individual browser implementation. JQuery seem to increase my productivity by multitudes. I was able to write much more JavaScript in less time. Since I wrote more code, there was more code to maintain and JQuery didn’t help with code maintainability.

In Early 2010 I started working with ASP.NET MVC. I feel in love with the technology. I was once again able to write HTML and JavaScript and I didn’t need to know the Page Life Cycle as I did in ASP.NET Web Forms. Looking back at ASP.NET Web Forms, I realize how many drawbacks it had.. The abstraction of basic HTTP that Microsoft created with ASP.NET Web Form complicated everything but the most basic application. The best part of the ASP.NET MVC was how the code was organized and encouraged the separation of concerns. The purpose of discussing ASP.NET MVC is that this was my first taste of MVC frameworks and much of the JavaScript technologies that I learned later are based on what I know in regards to ASP.NET MVC.

The JavaScript I wrote was getting more complicated. JQuery didn’t help with organizing all the code I was writing and it’s seemed that I was writing familiar code over and over. In late 2010 I was introduced to Knockout. Knockout implemented the Model-View-ViewModel (MVVM) pattern. This increased my productivity quite a bit. Now when my model was updated, the DOM would automatically be updated to represent the data in the model. And vice versa, if the DOM was updated through the browser, the model would automatically update. This help decrease the amount of code I was writing, but it didn’t decrease the complexity or reduce the amount of effort to maintain the code.

In mid-2011 I started investigating different JavaScript MV* libraries/frameworks and settled on Backbone.js. This was a very big learning curve. I was incorrect in my assumption that Backbone.js implemented the MVC pattern as similar to how ASP.NET implemented MVC. It took me weeks to get my head around Backbone.js. Once I did understand Backbone.js and that it was not a true MVC framework I was able to be very productive with the technology. Backbone.js provided me the code organization I needed and also provided a framework to create loosely coupled JavaScript. I became very proficient with Backbone.js. But, Backbone.js did have some negatives. The biggest drawback for me with Backbone.js was the amount of boiler plate code that had to be written.

In late 2012 while working with Backbone.js I started to see many articles about this framework called AngularJS, which was being developed by Google. Since I had such a big investment in time with Backbone.js I disregarded AngularJS. In early 2013 I interviewed with a company that needed someone that could work on all three layers (front, middle and backend). They mentioned that they were using AngularJS and really enjoyed working with it. We discussed AngularJS more and I became intrigued with the technology. The company changed direction and instead of needing someone with my skill set, they decided that they need an individual with mobile development experience, which practically I had very little. Even though I didn’t get hired by this company, the interviewing process was good and I came out with more knowledge than I went in with. I learned a lot in this interview and the technology that I dismissed (AngularJS) seemed to have a large following, but more importantly there were companies using it to create real-world application.

So in early 2013 I started learning AngularJS. I truly enjoy this technology. It seems by far that I’m more productive with AngularJS than the previous technologies. I can focus on the business issues at hand, and AngularJS tries to get out of the way. I write much less code than I previously did in other frameworks/libraries. AngularJS is very opinionated and that is good. Instead of learning multiple plugins for each framework, AngularJS has set of default components that work very nicely with each other. AngularJS is developed and support by Google. This is not a reason by-it-self to use AngularJS, but I believe it’s a big plus that such a large influential company is behind it. Google has put a large investment into AngularJS and there is an actual a team committed to it.

Knockout is a great library that supports data-binding with the MVVM pattern. It’s easy to learn and most people can be productive with it in a short time. Knockout is a library, it’s not a framework. It does a good job of data-binding, but doesn’t provide much else.

Backbone is a very good framework. Backbone is extremely flexible, but with this flexibility the developer must write more code. Backbone is considered as a MV* framework. Backbone doesn’t have an object that is considered controller. Many people believe that the controller is the Backbone router. Others believe, as I do, that the controller is the Backbone view. In the beginning this caused much confusion. Since there are so many different options of doing things in Backbone, I believe Backbone is more difficult to learn and to be productive with than Knockout and AngularJS. The framework is not opinionated and it’s up to developer to decide how to structure code. Terms are confusing in Backbone. For example, a Backbone View seems to be more of a controller and templates seems to be more similar to views. Data-binding must be coded by the developer. With Backbone, I believe it takes too much time and effort to productive and there’s a ton of code that must be written and maintained.

Of the current JavaScript frameworks/libraries available, I believe AngularJS has the brightest future. AngularJS is the most complete framework that includes dependency injection, data binding, custom HTML directives, routing, encourages MVC pattern, great for testing, good documentation, deep linking, and animation. For me, more important than anything else is that AngularJS gets out of my way and allows me to be very productive.

There will be other technologies that with surpass AngularJS, but for the time being AngularJS will be the MV* JavaScript framework I use.

4 thoughts on “How I Navigated to AngularJS”

Leave a Reply

Your email address will not be published. Required fields are marked *