Wednesday, April 30, 2014

Embular Part 2 - What's Great About Angular

Everyone knows that Angular is ridiculously popular. And for the most part the list of it's best features is well known, but for sake of comparison, here's my version of what makes Angular great:

Two-way binding to POJOs. Two-way binding is a must-have these days for JS frameworks. The fact that Angular was the first to market with robust two-way binding to "plain old JavaScript objects" (POJOs), is really what got it going I think.

Constructor-based Dependency Injection. This framework is built around its own IOC container that actually uses a pseudo-constructor-based DI approach that is generally preferred by developers from most contemporary backgrounds (such as Java or C#). This makes Angular highly testable, as well as providing the ability for Angular to easily detect circular dependencies.

Angular helps you organize your code. Angular has the idea of "modules" which help you break your code in reusable libraries. These could be the equivalent of a namespace in .NET or a package in Java. Angular's declaration patterns also help keep code out of global scope, for the most part. It also makes it easy to encapsulate these modules into single files, which would be like "assembly" or "jar" equivalents. This can be a very powerful tool when you're organizing large projects.

Simple bootstrapping. Angular has the simplest bootstrapping process of any modern framework I can think of. Just include one JS file, and add an ng-app directive to the page and you're in business.

Plain HTML for templating. In Angular, you don't have to learn much in the way of custom templating language. The only thing that's different from plain HTML is really the binding shorthand such as {{foo}}, which is generally optional.

You can extend HTML to do what you need it to do. Angular's directives allow you to create your own custom behaviors for any custom (or existing) HTML you choose. This is an incredibly powerful tool. It can be used to create reusable "controls", event bindings, interactions like modal dialogs or slider controls, and even validation.

It's flexible and stays out of the developer's way. Angular hands the developer a set of tools to develop a few primitives like Controllers, Services, Providers, and Views and then gets out of the way. This clears the path for the developer to create whatever he might need to create to get his/her project going, and in whatever way the developer chooses to do so. There are so many ways to skin a cat in Angular that it's pretty easy to discover a path to your goal.

Angular is easy to learn.  Angular's best feature is really a combination of all of the above. Aside from directives, Angular is very easy to learn. Its consistent API, use of plain HTML and plain JavaScript objects are an ingenious approach to a JavaScript application development platform not just because of the wizardry that's gone into developing Angular, but because it's so easy to pick up and use. Having worked in an environment where I had to get a team of 50-60 developers from "zero" to "proficient" in Angular, I can tell you it wasn't hard at all. Most of them just "got it".

It's backed by Google. Everyone knows that, and I think that helps some people "trust" Angular a bit more. Personally, I think this is a silly reason to choose a technology, but, c'est la vie, this is something that some people consider corporate backing when they're choosing a framework. One added benefit to a corporately backed OSS effort is there is a paid, full-time staff working on it.


NEXT: Embular Part 3 - What's Great About Ember

5 comments:

  1. > These could be the equivalent of a namespace in .NET or a package in Java.

    Stop telling people this, at least until it becomes true @___@

    ReplyDelete
    Replies
    1. Heh... but this is precisely how we were using Angular modules at Aesynt (McKesson Automation), and to pretty good effect. The only thing that isn't quite true about this statement is Angular IOC container/resolver is global, whereas most IOC containers in .NET or Java are going to be scoped only to what the current assembly or jar has referenced.

      Delete
  2. Oh my god, last two pros of Angular:
    Angular is easy to learn - heuheuheuheuheuheu.
    It's backed by Google - randomly killing this product is a pro now? Really?

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. I'm am as leery as the next person about Google's product whims, but this isn't a product. Additionally, while there are core maintainers/architects on the Google payroll, I think Angular has achieved critical mass in terms of public contribution and expertise. The project could definitely continue on and thrive if Google decided to spin it off and make it a purely publicly supported project.

      I say all that as someone who does somewhat prefer the community structure around Ember, which I think is a little more likely to be responsive the actual challenges faced by it's open-source contributors. However, I no longer think the difference between the two communities is so great that it's worth spending too much time on.

      Delete

This form allows some basic HTML. It will only create links if you wrap the URL in an anchor tag (Sorry, it's the Blogger default)