Conventions
We will explore some of the basic conventions and best practices both
in Ember and Ember CLI.
- Use
camelCaseeven if you are writingCoffeeScript. - Avoid globals as much as possible:
Ember CLIsupportsES6 Modulesout of the box so you can write your app in a modular way. - Create custom
shimsfor apps that are not distributed inAMDformat: we will cover this in a subsequent chapter, but the basic idea is to treat libraries that are not written withES6 Modulesas if they were. - Create reusable code: if there is a functionality you are using in several different places, remember that
Emberoffers an Ember.Mixin class that you can then reuse in different parts. If you think other people can benefit from this, create an add-on. - Name your files using kebab-case: Use hyphens instead of underscores to separate words in a file name. For example, if you have a model called
InvoiceItem,Ember CLIexpects this model to be underapp/models/invoice-item.js.