abuiles / ember-cli-101-errata

18 stars 4 forks source link

request: add explanation of Utils #243

Open bambery opened 9 years ago

bambery commented 9 years ago

edition: 2015-07-20 format: pdf page: 85

The first reference the book makes of utils is ember g util date-helpers on page 85, but it is unclear what the use case for utils are. I was unable to find documentation on the ember or ember-cli pages aside from http://www.ember-cli.com/user-guide/#using-pods, which doesn't clarify.

Why are the date helpers, which are stated to be "helper modules" in the book ("let's wrap them in a helper module") imported in utils (app/utils/date-helpers), wrapped in a helper function called formatDate, and then the util is imported into the helper (app/helpers/formatted-date) and wrapped again in a function called formatDate and exported again? What purpose does the util serve, and why is moment (or whichever of the various date formatters the chapter goes through) not imported directly into the helper?

I'm unclear when I should use a util, use a helper, or put functionality into a component or addon. The book has often helpfully linked to official doc or provided examples when introducing new concepts, and this one is still confusing to me.