-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pluralize and naming convention #48
Comments
TL;DRInstead of removing the collection at the end of a class name, we should instead remove the second level of namespacing e.g. Long VersionInitially, I was in favour of your idea but after thinking this through, I have decided against it for a number of reason: 1) Regular PluralsI think the most important convention to follow is that there should be a 1:1 relationship between classes and files. This is currently being broken because models and collections are placed in the same file but there is a proposal here to change this: #32 If that proposal were accepted, and I think it should be, then what about resources that have a shared singular and plural word e.g. sheep. This would mean you would have 2) Breaks Rails ConventionsThe convention in Rails is that everything but the model has the type of the class appended to it's name. Controllers, helpers and mailers all follow this convention and backbone is correctly extending this convention to views, routers and collections. 3) Internally InconsistentTo suggest that collections should break the above convention raises the question of why routers and views should be different (Models are already internally inconsistent but this inconsistency already exists in Rails and conformity to Rails is more important). To suggest that the same change should be extended to routers and views makes both of the above problems more problematic. The first problem would occur with any sort of plural as you would have a router with AlternativeHowever, the repetitiveness does bother me. Perhaps, therefore, it would be better to lose the second level of namespacing as this would resolve the repetition without resulting in any of the above problems. In other words, we should have the following:
Additionally, this has the advantage of being able to lose the |
In the model and scaffold generators it would be interesting to use and adapt rails naming convention.
Model would be singular and collection plural by default, it would be enforce by the generator.
class App.Models.Category
class App.Collections.Categories
Since most of the time the relationship between model and collection is 1 to 1.
And frankly App.Collections.CategoriesCollection feel a bit repetitive.
The text was updated successfully, but these errors were encountered: