AngularJS: Thoughts on Angular Way

The Basis

The "Angular Way" is based on several principles:

The Goal

The goal of "the Angular Way" is to make each component maximally deterministic, cohesive and independent and to promote the component composability.

Deterministic components

This means that every component has a well-defined and simple role in the system.

When working on a single module in parallel, all you need to know is how to communicate with your teammate's component (the contract, or interface, of his component).

The contracts are:

  • Directive's attributes
  • Controller's $scope bindings
  • Service's methods

Independent

Each component should have only limited amount of knowledge about its context.

Cohesive

Each component should have only one responsibility and, thus, the only one reason to change.

Composable

AngularJS let you write your code in declarative way: you write "what" your system should do, and not "how" it should do the stuff.

Resume

If you stick to "the Angular Way" and declarative approach in your design, you will be able to work with each distinct component independently and in a very limited context.

This means, that you won't lurk through the code of all dependencies trying to find what events should be listened to, and what those dependencies are doing, and how all that stuff is related to your current task.