Because it kindly stimulates any developer to deliver better code by promoting the use of proven design patterns without being overly opinionated.
I strongly believe that is also the reason why working with AngularJS makes every single developer a better one.
Out of the box. No strings attached. For free. Guaranteed. Period.
AngularJS doesn't require you to know a thing about design patterns. Understanding design patterns will definitely help you understand (and appreciate) AngularJS, but it is not required.
AngularJS kindly offers convenient wrappers, facades and factories to seemlessly let you use proven design patterns without you almost realizing it.
After working together with many different teams of developers in the past, I have noticed that most developers have their own programming style. In some cases you can almost tell who wrote some piece of code simply by reading it. Sometimes I liked reading the code, sometimes I didn't, even though the code worked perfectly.
AngularJS provides the necessary building blocks to leverage these styles in such a way that the end result is a comprehensive bundle of modules that is easy to use by other developers without requiring the whole team to know the inner workings of each module.
It conveniently provides developers with the freedom to program in their own style, but deliver pieces of code that can fluently be used by others without requiring large amounts of documentation.
By promoting the use of proven patterns to any developer, AngularJS can save you tons of frustration, time and money.
Proven design patterns
The true power of AngularJS' API is that it lets you conveniently apply design patterns out of the box, making your own code more re-usable, reliable, easier to test and above all simply better, because design patterns are patterns that are proven to provide solid solutions to problems.
It's not about how AngularJS is written, it's about the quality of the code it lets you produce.
This post is not meant as a technical study about all patterns used in and promoted by AngularJS, but here are a few examples:
AngularJS is built around modules and every application is defined as a module:
Each module can specify other modules as dependencies, allowing a developer to easily use existing modules without knowing the exact inner workings of every module.
Services in AngularJS are singletons, meaning they are only instantiated once:
Although AngularJS offers the
angular.service() convenience method, it is actually a wrapper around another method implementing the factory pattern:
You can watch properties of scopes and assign listeners to execute when a property changes:
Publish subscribe pattern
At the same time every
$scope can let you
$emit events, and attach event handlers that listen for such events using the
$on method. The scope basically acts as the middleman between publisher and subscriber to promote loose coupling:
$scope.$on(); $scope.$emit(); $scope.$broadcast();
Service decorators allow you to modify service behavior:
Without being overly opinionated
In my opinion that is what makes AngularJS so powerful:
- It does not require you to instantiate some base class to create a view.
- It does not offer you some out of the box model for handling collections.
- It does not require you to return objects implementing a predefined API.
As a consequence it is often mistaken for something it is not.
AngularJS is a foundation that offers great programming structures to help you build your own web application framework.
Deliver better code
While AngularJS is primarily known for popular features such as "two-way binding" and "directives", the main benefit for me has proven to be a non-technical one in that it kindly lets any developer use the built-in AngularJS methods to write quality code without having to know anything about design patterns.
And thus letting every member of the team build upon experiences of many developers that came before us.
Making every single developer in the team a better one.
Making every team better.
Thank you AngularJS!
Never miss an article again!
Have all awesomeness delivered directly to your inbox: