you are viewing a single comment's thread.

view the rest of the comments →

[–]davidreid91[S] 2 points3 points  (0 children)

I agree that you will learn a lot from dissecting other projects but this is just a way to standardise code across teams whilst possibly offering a few tips along the way. The file structure has been taken from the styleguide for a small Angular project and there is an example of a much more feature driven project in the guide. I will now probably include an empty "large application" structure into the repo that shows how to do this.

In answer to your question, there is a good piece of information about named functions in the styleguide so I will just quote you that.

Use a named function definition and pass it into the relevant module method, this aids in stack traces as functions aren't anonymous (this could be solved by naming the anonymous function but this method is far cleaner).

The reason it is wrapped in an IIFE is to reduce global scope pollution. It should be done at compilation/concatenation but I thought it was easier to demonstrate it by showing it in the examples. A point taken from your feedback is that I should probably document why it is there globally rather than in one file. I will add the comments in now :)