Blog

AngularJS: Why You Should Care

By Bill Lenoir

Development teams are always on the lookout for more powerful tools that allow them to build better web applications faster. And it feels like there has been an unending stream of them over the last decade. AngularJS, an open source framework out of Google, is the latest. I admit that I was hesitant to jump on the bandwagon, but my experience tells me this is worth it, as long as you take into account some potential pitfalls.

AngularJS is Different

We have had JavaScript since the mid-nineties. It is a veteran client-side scripting tool that adds brains to HTML’s skeleton and CSS’s beauty. In theory, you could replicate all of the functionality in every framework through plain JavaScript, but that would take an unreasonable amount of code to write, test and maintain.

JQuery was a giant leap forward. It simplified element manipulation, event handling and AJAX application development. What used to be a complicated, twister-like logic just to select a specific element on the page was reduced to a single line of code. This is great at the tactical level, but you still could not easily develop a dynamic view based on the content.

AngularJS, while still JavaScript, boils down the functionality such that you can pick and choose the parts that you need. No longer are you bound to the document object model (DOM). You now have tools that allow you to focus development where it matters:

  • Templates: These are a view into your application. As the data changes, the view changes. You no longer need to worry about that in your code.
  • Dependency Injection: Your web application no longer needs to be written as one mass of code. You can easily segregate presentation, data and control as needed to allow for a more easily maintainable and readable code-base.
  • Test Framework: More on this below, but understand that AngularJS was developed from the beginning to be easily testable.
  • Package Management: AngularJS is integrated with Bower, Node and other package management systems that automate the process of installing, upgrading, configuring and other aspects of ensuring AngularJS is up to date.

AngularJS is Easier to Test

Testing complicated JavaScript applications is not a straightforward exercise. Not that it’s impossible, but it is difficult to achieve true unit testing because, as I said above, the applications are a single mass of code. This makes it difficult to discover the source of problems when they are uncovered.

AngularJS, though, because it is compartmentalized, allows you to build a testing framework that can isolate functionality. This allows you to discover, diagnose and fix bugs faster than you would with traditional JavaScript applications.

AngularJS by itself is NOT SEO friendly

What a user sees on a web page generated by AngularJS (or any other AJAX framework) differs greatly from what a crawler from Google or other search engines see. This means that unless you take steps to rectify this, your content will not be findable on these search engines.

A key decision point on whether or not to use AngularJS is how important SEO is to your content. If the whole site needs to be crawable, you should probably forgo AngularJS. If you don’t care at all, fine. If you’re somewhere in between, you will need to factor into your level of effort the time and resources needed to develop an HTML snapshot the crawlers can read.

AngularJS is NOT a UI Framework

There is nothing in AngularJS that enhances the look and feel of a page. The focus of this tool is on the content and how it is structured. You could stick with old fashioned CSS, but then you’d still need some sort of JavaScript to get enhanced effects. AngularUI is a set of stand-alone modules that provide some of this functionality. Your best bet, though, would be the Angularized version of Bootstrap. If you are already using Bootstrap in your application, only the JavaScript portions would need to be re-written, and even that is not much effort.

Conclusion: AngularJS is Great for Web Apps, not Pure Content Plays

If you are developing a web application that does not need to be crawled by search engines, then AngularJS makes sense since it streamlines your development and, perhaps more importantly, your testing. For more traditional web feature sets, AngularJS is probably over-kill. Don’t be sad, though, JQuery is still a very powerful tool.

Categories: Blog, Modernization, Technology Strategy

Tags: , , , , ,

Bill Lenoir
11 Jan, 2015