Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composed names on services is not a good idea. #72

Closed
Foxandxss opened this issue Aug 28, 2014 · 7 comments
Closed

Composed names on services is not a good idea. #72

Foxandxss opened this issue Aug 28, 2014 · 7 comments

Comments

@Foxandxss
Copy link
Contributor

Hey @sahat . You new convention of satellizer.foo to name the different services is not a good idea.

That only works with array notation like:

app.controller('foo', ['satellizer.Oauth2', function(Oauth2) {

}]);

but not with:

app.controller('foo', function(satellizer.Oauth2) {

});

For internal usage is ok because you are using the first mode, but if I want to override or decorate something, you are forcing me to use array notation.

I would think about our own prefix like: ss (s from sahat and s from stallizer) or even stl (satellizer).

ssOuath2, stlOauth2 or something like that.

What do you think?

@sahat
Copy link
Owner

sahat commented Aug 28, 2014

It is fine. I have given it much thought and looked at plenty of style guides and examples regarding namespacing so this is not too uncommon. Since I am no longer using ngAnnotate I have to inline annotate anyway.

Anything prefixed with satellizer. is not meant to be extendable or overridable, it is for internal usage only. Once AngularJS 2.0 comes around I will make all those services private.

@Foxandxss
Copy link
Contributor Author

Alright, as always I respect your decisions, I just point out things that are more weird. I never saw that namespacing tbh and I done a lot of angular so far.

Leave it as is then, if it is not mean to be decorated by end users, good enough :)

@sahat
Copy link
Owner

sahat commented Aug 28, 2014

You might be right, I may have confused it with module namespacing notation, which is very common. Either way it's just an internal implementation detail.

We can discuss whether to keep it or switch to camelCase later, after all primary issues are fixed.

@Foxandxss
Copy link
Contributor Author

Yes, module notation is different, but yes, let's talk about that after things are fixed.

@sahat
Copy link
Owner

sahat commented Aug 28, 2014

@Foxandxss If I namespace each service into its own module called satellizer.popup for example, and then require it in the main satellizer module like so:

angular.module('satellizer', ['satellizer.popup']);

Will satellizer.popup module be private if someone includes the main satellizer module in their app?

angular.module('MyApp', ['ngResource', 'ngMessages', 'ngRoute', 'satellizer', 'mgcrea.ngStrap'])

@stryju
Copy link
Contributor

stryju commented Aug 28, 2014

no, it will be "public", so i can use it like:

angular.module('foo', ['satellizer.popup'])

can't really see how that causes an issue, tho :-)

@Foxandxss
Copy link
Contributor Author

The thing is, why you need private? You don't. People will still inject "satellizer" to use the library, but if they need to inject the other inner services for something, let them do it!, You shouldn't restrict what they can do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants