monterail / guidelines

[DEPRECATED] We are Ruby on Rails experts from Poland. Think hussars. Solid & winged. These are our guidelines.
71 stars 17 forks source link

Group params in angular dependency injection #211

Closed jandudulski closed 10 years ago

jandudulski commented 10 years ago

I often see total mess in order how DI params are passed into angular functions. My personal preference is to keep it in such way:

So instead of:

angular.module('app').controller 'Something', ($scope, Project, $http, user) ->

it should be:

angular.module('app').controller 'Something', ($scope, $http, user, Project) ->
venticco commented 10 years ago

:+1:

lukaszwnek commented 10 years ago

:+1: I do it exactly that way!

tallica commented 10 years ago

I follow that rule already! :+1:

jcieslar commented 10 years ago

Good :+1: but I prefer:

teamon commented 10 years ago

I'd start with most common ones and end with most specific so :+1: for @jcieslar's version

sheerun commented 10 years ago

I'd also make an assignment to make more room for injected dependencies.

App = angular.module('app')

App.controller 'Something', ($scope, Project, $http, user) ->

For more injected dependencies, it is:

App = angular.module('app')

App.controller 'Something', (
  $scope, $compile, Service,
  Project, $http, user, notes
) ->
sheerun commented 10 years ago

And the same as in SLIM: 80 characters hard limit before word wrap

Ostrzy commented 10 years ago

I don't like idea with assignment, but :+1: for @jcieslar version

hodak commented 10 years ago

:+1: for @jcieslar's version - it's easier to distinguish $-services from objects when they are after Capitalized classes

App.controller 'Something', ($scope, $compile, user, Project)
App.controller 'Something', ($scope, $compile, Project, user)