Skip to content
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

Removing some magic to make naming conventions more sane #218

Closed
wants to merge 1 commit into from
Closed

Removing some magic to make naming conventions more sane #218

wants to merge 1 commit into from

Conversation

mikegrassotti
Copy link
Contributor

Related: #184

Still a wip, this is where steph and i left off when pairing earlier.

@dustinfarris
Copy link
Contributor

So does this mean no hyphens in filenames going forward?

@stefanpenner
Copy link
Owner

@dustinfarris yes, that is the idea. The reasoning is, less ambiguity === a good thing.

I would be interested in hearing others thoughts on this, as I know I tend to prefer to avoid ambiguity + unneeded complexity.

@thomasboyt
Copy link
Contributor

really can't see a case where allowing both would lead to ambiguity; the only "complicated" part of this is within the resolver, not anything that gets customized

@CodeOfficer
Copy link
Contributor

I have been bitten many times trying to figure out where ember wants under_score, lowerCamelCase or dash-er-ized strings ... I'd love to see it only work one way here. Normalizing isn't always a feature.

@stefanpenner
Copy link
Owner

@thomasboyt I would prefer we make this strict for now, we can always loosen the constraints later.

@thomasboyt
Copy link
Contributor

Module names can be either "snake case" (app/controllers/some_thing.js) or "dasherized" (app/controllers/some-thing.js), depending on your personal preferences.

This seems user-friendly and not confusing to me. If we had a solid technical reason for changing this, I'd be okay with it, but I'm not seeing it.

Here's the situation after this change:

  • Objects: camelCase
  • Helpers: dasherized
  • Components: force dasherized, this is going to be very confusing IMO
  • View helpers: {{view "snake_case"}}, {{partial "snake_case"}}, etc.

If we do this, we need to make it clear that view helpers are using module names (i.e. file names) and that components have different file name rooms (or autoconvert snake case component names to dasherized)

@stefanpenner
Copy link
Owner

The current implementation utilizes a hack I added to almond to inspect the "registry" to make the choice. The only other option I see is wrapping require is a try/catch and attempting the other variation.

Additionally, I see little win for supporting both.


if (parsedName.fullName === 'router:main') {
// for now, lets keep the router at app/router.js
return require(prefix + '/router');
}

if (requirejs._eak_seen[normalizedModuleName]) {
try {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice if require supported has

@MajorBreakfast
Copy link
Contributor

We should use either camelCase, snake_case or dashes. The javascript world generally aggrees on using dashes for filenames. And with ember this seems to be a good idea, too. this.route('some-stuff');, SomeStuffRoute in app/routes/some-stuff.js with the nice www.example.com/some-stuff url. I don't really care how the files are named, because they don't appear in the final product anyway, but the documentation should have a clear recommendation. A few months ago we had this ambiguitiy with the handlebars helper syntax. It's far better now.

@stefanpenner
Copy link
Owner

@MajorBreakfast we aim to only use dashes. 0 ambiguity is very important.

type-of-thing@namespace:something/name-of-thing

@stefanpenner
Copy link
Owner

@mikegrassotti have any time to continue working on this one?

@ianpetzer
Copy link
Contributor

@stefanpenner The WIP commit that started this discussion seemed to converting dasherized-filenames to underscored_file_names ...

@@ -74,31 +58,33 @@ define("resolver",

// allow treat all dashed and all underscored as the same thing
// supports components with dashes and other stuff with underscores.
var normalizedModuleName = chooseModuleName(requirejs._eak_seen, moduleName);
var normalizedModuleName = Ember.String.underscore(moduleName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line also seems to indicate that you are moving to underscored names instead of dasherized names

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on disk underscored, in ember dasherized.

@MajorBreakfast
Copy link
Contributor

  • On disk: Dasherized folder names, snake case javascript file names (this one is new to me, but is the case in ember source)
  • Module names: dasherized
  • Methods, classes, etc. in javascript/json files: camel case
  • CSS classes: dasherized

Is that it?

@stefanpenner
Copy link
Owner

on disk: snake_cased everything
moduleNames: snake_cased (to reflect the disk)
fullNames (the container keys, needs, store.find(..)): dasherized as for the most part "vague" things in the browser seem dasherized.
javascript syntax: camel
css classes: dasherized

@ianpetzer
Copy link
Contributor

Great.. Thanks for the clarificaiton

On Fri, Oct 18, 2013 at 2:56 PM, Stefan Penner notifications@github.comwrote:

on disk: snake_cased everything
moduleNames: snake_cased (to reflect the disk)
fullNames (the container keys, needs, store.find(..)): dasherized
javascript syntax: camel
css classes: dasherized


Reply to this email directly or view it on GitHubhttps://github.com//pull/218#issuecomment-26593248
.

@MajorBreakfast
Copy link
Contributor

Snake case module names might be a bad idea, because node modules are always dasherized. I think npm even enforces that.

@stefanpenner
Copy link
Owner

@MajorBreakfast interesting... then maybe we must dasherize

@mikegrassotti
Copy link
Contributor Author

Despite the commit message I am not against dashes. Just as long as we are consistent.


Sent from Mailbox for iPhone

On Fri, Oct 18, 2013 at 5:14 PM, Stefan Penner notifications@github.com
wrote:

@MajorBreakfast interesting... then maybe we must dasherize

Reply to this email directly or view it on GitHub:
#218 (comment)

@MajorBreakfast
Copy link
Contributor

File names often end up in urls and most sites prefer dashes there, too. So, modules AND file/folder names dasherized?

stefanpenner referenced this pull request in DavyJonesLocker/ember-appkit-rails Oct 29, 2013
@stefanpenner
Copy link
Owner

@Pradeek
Copy link
Contributor

Pradeek commented Nov 28, 2013

I agree with @MajorBreakfast here. Why do we want file names to be underscored when module names have to be dasherized? If we want one convention to rule them all, we should be switching completely to dashes instead. Also, components (both Ember and web component spec) enforce dashes, so dashes should be the convention going forward.

@stefanpenner
Copy link
Owner

I'm for 1 convention to rule them all, dasherized in all the places would be fine with me. (i believe)

@stefanpenner
Copy link
Owner

this work has been pushed to https://github.com/stefanpenner/ember-jj-abrams-resolver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants