today I want to share with you fragment of knowledge from John Papa and his course at pluralsight entitled AngularJS Patterns: Clean Code.
Inside of course one of the videos he have following structure advice: Function, Inject, Register ( I will name it FIR ).
or in the form of image:
And as John Papa mentioned, Todd Motto also likes that approach:
"I prefer this sequence: write my function, inject the dependencies, ship it off into the app. It makes sense from hoisting and declarative prospectives".
But in one of projects where I used to work, company had another approach: Register, Inject, Function. You maybe can ask: "Why?". The answer is pretty simple: if your function is pretty big, then it can be not convenient to scroll it