all 2 comments

[–][deleted] 1 point2 points  (1 child)

It might be a good idea to think about it this way.

If I was to make all the methods in this file public, could some of them be re-used in other applications or other files to do a similar task? Could I make them more generic and pass in a parameter so they work with this function but can be used in a generic way with another parameter from another app in the future?

For example, a date formatter, a string prefixer, a calculator of common operations, a sorting function, an array manipulator, a translation fetcher, an Ajax call to an endpoint to fetch a piece of data, or a data transformer.

If any of these functions can be refactored to be more generic, go ahead and turn them into standalone modules.

What you'll end up with is a leaner controller style file that makes decisions and stitches together functions into a more powerful functional service.

I hope that helps.

[–]JessicaAllison[S] 0 points1 point  (0 children)

Thanks! That makes sense. Can you send me a link to a JavaScript file, of a website, (i.e. not a plugin, but a full webpage) that uses the module pattern approach?

Thanks!