Why does Angular recommend puttings services, directives, and filters in separate modules?

In the angular-seed-project the filters, services, and directives are placed in different modules. Why? Why not stick them all under the myApp module?

angular.module('myApp', ['myApp.filters', 'myApp.services', 'myApp.directives'])

Quoting from [1]


"...we recommend that you break your application to multiple modules like this:

  • A service module, for service declaration
  • A directive module, for directive declaration
  • A filter module, for filter declaration
  • And an application level module which depends on the above modules, and which has initialization code.

The reason for this breakup is that in your tests, it is often necessary to ignore the initialization code, which tends to be difficult to test. By putting it into a separate module it can be easily ignored in tests. The tests can also be more focused by only loading the modules that are relevant to tests.

The above is only a suggestion, so feel free to tailor it to your needs."


[1] http://docs.angularjs.org/guide/module