Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Please consider deprecating inferred dependencies #6717

Closed
AdrianRossouw opened this issue Mar 17, 2014 · 1 comment
Closed

Please consider deprecating inferred dependencies #6717

AdrianRossouw opened this issue Mar 17, 2014 · 1 comment

Comments

@AdrianRossouw
Copy link

Hey There.

I've been working through what was troubling me about angular as a platform,
and I think I finally got it down to the fact that I think that the black magic around
inferred dependencies are going to cause a significant problem for the future
maintainability.

I'm not really angular's model user, because I understand that there's almost never going to be a situation where it's the right tool for what I am doing.

I was however one of the major core contributors for Drupal for many years, and although I'm no longer involved I have been able to see the effects that design decisions in major API's I have built have when used by thousands of developer over almost a decade.

That's not an appeal to authority, just letting you know from what perspective I am looking at this at. I think this is going to be a really big problem 5-10 years from now if you don't take a stand now.

I also think there is a way to keep everyone happy. It's all detailed in my blog.

http://daemon.co.za/2014/03/complexity-creeps-concerned-for-future-of-angular/

@btford
Copy link
Contributor

btford commented Mar 17, 2014

FYI this "problem" will not exist in ng 2.0. You can look at our new DI system on GitHub: https://github.com/angular/di.js

We (the angular team) agree that the DI annotations are added complexity.

If you have some specific changes in mind for the documentation, feel free to submit PRs to address them. Thanks!

@btford btford closed this as completed Mar 17, 2014
caitp added a commit to caitp/angular.js that referenced this issue Mar 17, 2014
This modifies the injector to prevent automatic annotation from occurring for a given injector.

This works by passing a `true` as the 3rd or 4th parameter to createInjector(), or alternatively
to angular.module.

```js
angular.module("name", ["dependencies", "otherdeps"], configFn, true)
  .provider("$willBreak", function() {
    this.$get = function($rootScope) {
    };
  })
  .run(["$willBreak", function($willBreak) {
    // This block will never run because the noMagic flag was set to true, and the $willBreak
    // '$get' function does not have an explicit annotation.
  });
```

This will only affect functions with an arity greater than 0, and without an $inject property.

Related: angular#6717
caitp added a commit to caitp/angular.js that referenced this issue Mar 17, 2014
This modifies the injector to prevent automatic annotation from occurring for a given injector.

This works by passing a `true` as the 3rd or 4th parameter to createInjector(), or alternatively
to angular.module.

```js
angular.module("name", ["dependencies", "otherdeps"], configFn, true)
  .provider("$willBreak", function() {
    this.$get = function($rootScope) {
    };
  })
  .run(["$willBreak", function($willBreak) {
    // This block will never run because the noMagic flag was set to true, and the $willBreak
    // '$get' function does not have an explicit annotation.
  }]);
```

This will only affect functions with an arity greater than 0, and without an $inject property.

Related: angular#6717
caitp added a commit to caitp/angular.js that referenced this issue Apr 1, 2014
This modifies the injector to prevent automatic annotation from occurring for a given injector.

This works by passing a `true` as the 3rd or 4th parameter to createInjector(), or alternatively
to angular.module.

```js
angular.module("name", ["dependencies", "otherdeps"], configFn, true)
  .provider("$willBreak", function() {
    this.$get = function($rootScope) {
    };
  })
  .run(["$willBreak", function($willBreak) {
    // This block will never run because the noMagic flag was set to true, and the $willBreak
    // '$get' function does not have an explicit annotation.
  }]);
```

This will only affect functions with an arity greater than 0, and without an $inject property.

Related: angular#6717
caitp added a commit to caitp/angular.js that referenced this issue Apr 2, 2014
This modifies the injector to prevent automatic annotation from occurring for a given injector.

This works by passing a `true` as the 3rd or 4th parameter to createInjector(), or alternatively
to angular.module.

```js
angular.module("name", ["dependencies", "otherdeps"], configFn, true)
  .provider("$willBreak", function() {
    this.$get = function($rootScope) {
    };
  })
  .run(["$willBreak", function($willBreak) {
    // This block will never run because the noMagic flag was set to true, and the $willBreak
    // '$get' function does not have an explicit annotation.
  }]);
```

This will only affect functions with an arity greater than 0, and without an $inject property.

Related: angular#6717
caitp added a commit to caitp/angular.js that referenced this issue Apr 2, 2014
This modifies the injector to prevent automatic annotation from occurring for a given injector.

This works by passing a `true` as the 3rd or 4th parameter to createInjector(), or alternatively
to angular.module.

```js
angular.module("name", ["dependencies", "otherdeps"], configFn, true)
  .provider("$willBreak", function() {
    this.$get = function($rootScope) {
    };
  })
  .run(["$willBreak", function($willBreak) {
    // This block will never run because the noMagic flag was set to true, and the $willBreak
    // '$get' function does not have an explicit annotation.
  }]);
```

This will only affect functions with an arity greater than 0, and without an $inject property.

Related: angular#6717
caitp added a commit to caitp/angular.js that referenced this issue Apr 7, 2014
This modifies the injector to prevent automatic annotation from occurring for a given injector.

This works by passing a `true` as the 3rd or 4th parameter to createInjector(), or alternatively
to angular.module.

```js
angular.module("name", ["dependencies", "otherdeps"], configFn, true)
  .provider("$willBreak", function() {
    this.$get = function($rootScope) {
    };
  })
  .run(["$willBreak", function($willBreak) {
    // This block will never run because the noMagic flag was set to true, and the $willBreak
    // '$get' function does not have an explicit annotation.
  }]);
```

This will only affect functions with an arity greater than 0, and without an $inject property.

Related: angular#6717
caitp added a commit to caitp/angular.js that referenced this issue Apr 9, 2014
This modifies the injector to prevent automatic annotation from occurring for a given injector.

This works by passing a `true` as the 3rd or 4th parameter to createInjector(), or alternatively
to angular.module.

```js
angular.module("name", ["dependencies", "otherdeps"], configFn, true)
  .provider("$willBreak", function() {
    this.$get = function($rootScope) {
    };
  })
  .run(["$willBreak", function($willBreak) {
    // This block will never run because the noMagic flag was set to true, and the $willBreak
    // '$get' function does not have an explicit annotation.
  }]);
```

This will only affect functions with an arity greater than 0, and without an $inject property.

Related: angular#6717
caitp added a commit to caitp/angular.js that referenced this issue Apr 10, 2014
This modifies the injector to prevent automatic annotation from occurring for a given injector.

This works by passing a `true` as the 3rd or 4th parameter to createInjector(), or alternatively
to angular.module.

```js
angular.module("name", ["dependencies", "otherdeps"], configFn, true)
  .provider("$willBreak", function() {
    this.$get = function($rootScope) {
    };
  })
  .run(["$willBreak", function($willBreak) {
    // This block will never run because the noMagic flag was set to true, and the $willBreak
    // '$get' function does not have an explicit annotation.
  }]);
```

This will only affect functions with an arity greater than 0, and without an $inject property.

Related: angular#6717
caitp added a commit to caitp/angular.js that referenced this issue Apr 10, 2014
This modifies the injector to prevent automatic annotation from occurring for a given injector.

This works by passing a `true` as the 3rd or 4th parameter to createInjector(), or alternatively
to angular.module.

```js
angular.module("name", ["dependencies", "otherdeps"], configFn, true)
  .provider("$willBreak", function() {
    this.$get = function($rootScope) {
    };
  })
  .run(["$willBreak", function($willBreak) {
    // This block will never run because the noMagic flag was set to true, and the $willBreak
    // '$get' function does not have an explicit annotation.
  }]);
```

This will only affect functions with an arity greater than 0, and without an $inject property.

Related: angular#6717
caitp added a commit to caitp/angular.js that referenced this issue Apr 10, 2014
…annotation

This modifies the injector to prevent automatic annotation from occurring for a given injector.

This behaviour can be enabled when bootstrapping the application by using the attribute
"ng-strict-di" on the root element (the element containing "ng-app"), or alternatively by passing
an object with the property "strictDi" set to "true" in angular.bootstrap, when bootstrapping
manually.

JS example:

    angular.module("name", ["dependencies", "otherdeps"])
      .provider("$willBreak", function() {
        this.$get = function($rootScope) {
        };
      })
      .run(["$willBreak", function($willBreak) {
        // This block will never run because the noMagic flag was set to true,
        // and the $willBreak '$get' function does not have an explicit
        // annotation.
      }]);

    angular.bootstrap(document, ["name"], {
      strictDi: true
    });

HTML:

    <html ng-app="name" ng-strict-di>
      <!-- ... -->
    </html>

This will only affect functions with an arity greater than 0, and without an $inject property.

Closes angular#6719
Closes angular#6717
Closes angular#4504
Closes angular#6069
Closes angular#3611
caitp added a commit to caitp/angular.js that referenced this issue Apr 11, 2014
…annotation

This modifies the injector to prevent automatic annotation from occurring for a given injector.

This behaviour can be enabled when bootstrapping the application by using the attribute
"ng-strict-di" on the root element (the element containing "ng-app"), or alternatively by passing
an object with the property "strictDi" set to "true" in angular.bootstrap, when bootstrapping
manually.

JS example:

    angular.module("name", ["dependencies", "otherdeps"])
      .provider("$willBreak", function() {
        this.$get = function($rootScope) {
        };
      })
      .run(["$willBreak", function($willBreak) {
        // This block will never run because the noMagic flag was set to true,
        // and the $willBreak '$get' function does not have an explicit
        // annotation.
      }]);

    angular.bootstrap(document, ["name"], {
      strictDi: true
    });

HTML:

    <html ng-app="name" ng-strict-di>
      <!-- ... -->
    </html>

This will only affect functions with an arity greater than 0, and without an $inject property.

Closes angular#6719
Closes angular#6717
Closes angular#4504
Closes angular#6069
Closes angular#3611
caitp added a commit that referenced this issue Apr 11, 2014
…annotation

This modifies the injector to prevent automatic annotation from occurring for a given injector.

This behaviour can be enabled when bootstrapping the application by using the attribute
"ng-strict-di" on the root element (the element containing "ng-app"), or alternatively by passing
an object with the property "strictDi" set to "true" in angular.bootstrap, when bootstrapping
manually.

JS example:

    angular.module("name", ["dependencies", "otherdeps"])
      .provider("$willBreak", function() {
        this.$get = function($rootScope) {
        };
      })
      .run(["$willBreak", function($willBreak) {
        // This block will never run because the noMagic flag was set to true,
        // and the $willBreak '$get' function does not have an explicit
        // annotation.
      }]);

    angular.bootstrap(document, ["name"], {
      strictDi: true
    });

HTML:

    <html ng-app="name" ng-strict-di>
      <!-- ... -->
    </html>

This will only affect functions with an arity greater than 0, and without an $inject property.

Closes #6719
Closes #6717
Closes #4504
Closes #6069
Closes #3611
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants