Skip to content
This repository has been archived by the owner on Sep 13, 2017. It is now read-only.

Namespace Conflict: Journey is a very generic name #49

Closed
samlown opened this issue Sep 19, 2012 · 25 comments
Closed

Namespace Conflict: Journey is a very generic name #49

samlown opened this issue Sep 19, 2012 · 25 comments

Comments

@samlown
Copy link

samlown commented Sep 19, 2012

Hi. Sorry for arriving a bit late here, but we only just got round to starting an upgrade to Rails 3.2.

Unfortunately, we have a model in our project called "Journey". This causes a conflict with this new Journey module in Rails 3.2.

Firstly, is there a known way to get around this issue? (I can't think of any, but you never know.)

Secondly, could you consider renaming the project to something that isn't a common noun? Even a made-up verbal noun would be better than "journey", like "journeying", "journeyer", "travelling", or "actionjourney". Who cares to be honest, as far as I can tell no one is every actually going to type it in except the few programmers maintaining ActionPack and the project itself.

I really hope this can be resolved, in the meantime we're rolling back to Rails 3.1.

@codker
Copy link

codker commented Sep 20, 2012

Why don't you use a namespace? So you can use Journey for your model and from the gem

@samlown
Copy link
Author

samlown commented Sep 20, 2012

A namespace would work, but its a serious amount of effort to rename everything. Its been my experience that namespacing models in Rails is generally more effort than its worth.

The solution I have in mind at the moment, if I can't convince anyone to rename, is to write a couple of Rake tasks to automatically rename Journey in journey and ActionPack branches. When a new release comes out, merge from release tag and re-run rake. Seriously lame, but quite considerably easier than renaming our project.

@tenderlove
Copy link
Member

Probably we could rename this library, but it means a major revision name. The thing is, humans are not clairvoyant (that I know of). Any name chosen could possibly conflict with other projects, however no gem name was taken when I released this. What makes your private project (that I would have no idea about) more important than mine?

Aaron Patterson
http://tenderlovemaking.com/
I'm on an iPhone so I apologize for top posting.

On Sep 20, 2012, at 5:55 PM, Sam Lown notifications@github.com wrote:

A namespace would work, but its a serious amount of effort to rename everything. Its been my experience that namespacing models in Rails is generally more effort than its worth.

The solution I have in mind at the moment, if I can't convince anyone to rename, is to write a couple of Rake tasks to automatically rename Journey in journey and ActionPack branches. When a new release comes out, merge from release tag and re-run rake. Seriously lame, but quite considerably easier than renaming our project.


Reply to this email directly or view it on GitHub.

@codker
Copy link

codker commented Sep 20, 2012

that's the point, I'm with @tenderlove. If you have name conflict with external gems, you should take action, not the other way around.

Simply take the effort to namespace your model if it's so important to call it Journey.
I don't get why it's less effort to write a rake task to mess with Journey router code, rather than write a bunch of YourNamespace::Journey and forget about it.

@pixeltrix
Copy link

Its been my experience that namespacing models in Rails is generally more effort than its worth.

This may have been true in the past but I regularly use namespaced models (both nested models and models inside a module) without any problems.

As for renaming your model why not use Trip? There doesn't seem to be any collision issues with a gem for that one.

@samlown
Copy link
Author

samlown commented Sep 20, 2012

What makes your private project (that I would have no idea about) more important than mine?

Absolutely nothing :-)

My only line of reasoning is that "Journey" is a very generic common noun, which many other developers are likely to use now and in the future. It is my newly formed belief (frankly, I never thought about this before) that projects should not be named after common nouns as these are the names more likely to be used by data modellers to describe things in the physical world.

I guess this doesn't come up very often because there are very few projects that use common nouns. Rack is about the only gem required by Rails in a similar situation.

Journeys are our business, it is the core of everything we do. Renaming would be totally impractical. We don't just use it in Rails, we use it in our Node.js server, Android app, and iOS (Obj-C, Rubymotion [1]) apps, with more in the pipeline. Whereas Journey is mentioned 15 times in ActionPack. IMHO it is far easier for us in the long term (given how often we upgrade rails) to create a quick rake task to search and replace.

I really hope you understand my predicament.

[1] http://blog.rubymotion.com/post/30514580062/rubymotion-success-story-cabify

@tenderlove
Copy link
Member

Remaning the gem is also very impractical. It means breaking anyone that relies on the current constants. Breaking current constants means that I must release a major version. We don't want to switch Rails's dependencies to a major version in a bugfix release.

I understand your predicament, but can you see mine? It impacts many people and if I want to follow semver (which I do), it takes much more time than doing a quick release.

Journeys are our business, it is the core of everything we do. Renaming would be totally impractical.

I'm open to helping, but this kind of logic doesn't sway me. "Journeys" being the core of your business doesn't make changing code impractical. Can you offer a solution besides "please rename your gem"? TBH, I'm partial to pushing the router back in to Rails, but that certainly won't happen for Rails 4 (or a bug release version).

@georgeguimaraes
Copy link

This spurs a interesting discussion (at least for me): as gems creators (and maintainers), what are the precautions one has to think of when naming a global constant?

Is there any discussion on this already opened in mailing lists or github?

@samlown
Copy link
Author

samlown commented Sep 20, 2012

I totally appreciate that it would not be possible without a major release, I certainly wouldn't hope for a modification to the current Rails 3.2, way too late for that.

It would be great if this could be considered for Rails 4 though, or at least have a new name before then so I can run my own patched version of Rails 3.2.

A quick google search [1] suggests that 'journey' is only used by ActionPack, nothing else. This is pure speculation, but I don't see much evidence to believe many people would actually notice if the name was changed.

I really don't have anything else to go on here in terms of solutions. I can only try to appeal to your nice natures and suggest that common nouns should not be used for the names of projects. I'd certainly be willing to offer a couple of pull requests with a new name if that helps...

[1] site:gemcutter.org dependencies journey -replacement

@rafaelfranca
Copy link
Member

In one of my projects I check for the Journey constant. It is not a open source project but renaming it would make me to change my code.

@vampirechicken
Copy link

On Thu, Sep 20, 2012 at 12:40 PM, Sam Lown notifications@github.com wrote:

I totally appreciate that it would not be possible without a major
release, I certainly wouldn't hope for a modification to the current Rails
3.2, way too late for that.

It would be great if this could be considered for Rails 4 though, or at
least have a new name before then so I can run my own patched version of
Rails 3.2.

A quick google search [1] suggests that 'journey' is only used by
ActionPack, nothing else. This is pure speculation, but I don't see much
evidence to believe many people would actually notice if the name was
changed.

Might I suggest ActionRouter or ActiveRouter.

lenjaffe@lenjaffe.com 614-404-4214
Proprietor: http://www.theycomewithcheese.com/ - An Homage to Fromage
Grubmaster: Greenbar http://www.greenbartraining.org/ 2011, 2010, 2009,
Grub Asst. 2008, Trained 2007.

@dball
Copy link

dball commented Sep 20, 2012

If the suggested intervention is for @samlown to namespace his models, might it then make sense for Rails 4 to start generating application models and other classes in the application namespace by default?

@tenderlove
Copy link
Member

It would be great if this could be considered for Rails 4 though, or at least have a new name before then so I can run my own patched version of Rails 3.2.

I think we have time for Rails 4 to rename (though if someone made the patches for me, I would appreciate it).

Might I suggest ActionRouter or ActiveRouter.

I'm fine with either of these.

@rafaelfranca what are you trying to detect by looking for the constant? Maybe there is something we need to do better?

@fxn
Copy link
Member

fxn commented Sep 23, 2012

Editorial note for whoever does the patch :). To be coherent with the naming conventions in Rails ActionRouter would be the name of the Ruby module. And "Action Router" the name of the component itself.

@pixeltrix
Copy link

Wouldn't it make more sense to move it to the ActionDispatch namespace (as ActionDispatch::Router I guess) - after all that's where most of the code that interfaces with it is and we may be able to streamline some things once it's in there.

@pixeltrix
Copy link

Actually looking at it ActionDispatch::Routing::Router makes the most sense - the only real thing that would be a bit of a mess is Journey::Routes and ActionDispatch::RouteSet, as the latter is essentially a wrapper around the former so we'd probably want to merge those two in some way.

@tenderlove
Copy link
Member

@pixeltrix you may be right, but I think that would mean shipping the existing Journey code along with the AP gem. Renaming the gem may be a less extreme change.

That said, I'm not against pushing the code in to AD. The main reason is that I think the routing code was prematurely extracted from Rails. I like the idea of having a separate gem that knows how to route, but the interface is so complex (and specific) that basically only Rails can use it. I'd like to extract a better object model for the router.

Opinions are definitely welcome!

@rafaelfranca
Copy link
Member

@tenderlove I searched in the code and I'm not checking the constant anymore.

I think is a good path renaming the Journey to Action Router.

@jeremy
Copy link
Member

jeremy commented Sep 24, 2012

Your constant name is already in use. You may want to try

  • Journey0001
  • Journey1973
  • Jurrney
  • FrumiousBandersnatch

❤️ ruby

@tenderlove
Copy link
Member

@jeremy :trollface:❤️

@pixeltrix
Copy link

@pixeltrix you may be right, but I think that would mean shipping the existing Journey code along with the AP gem. Renaming the gem may be a less extreme change.

Whether it's in a separate gem or in the AP gem gem it's still the same weight of code - it's not like anyone would use AP with something other than Journey - one less dependency for Bundler to resolve.

That said, I'm not against pushing the code in to AD. The main reason is that I think the routing code was prematurely extracted from Rails. I like the idea of having a separate gem that knows how to route, but the interface is so complex (and specific) that basically only Rails can use it. I'd like to extract a better object model for the router.

Agree on the premature extraction - perhaps re-integrate for now and look to a general purpose router for Rack 2 (whatever the status of that is).

@bakongo
Copy link

bakongo commented Nov 1, 2012

I've got the same problem: Rails 3.2 upgrade from 2.3.x, and a model named Journey.
Took me a fair bit of time to figure out that this was the problem, actually.

@samlown, did you end up namespacing Journey, or write those rake tasks?

@samlown
Copy link
Author

samlown commented Nov 1, 2012

@bakongo we've been too busy and not really had a need to upgrade from 3.1 yet. I'll post a gist when we have something.

@vampirechicken
Copy link

Not for nothing, this is a problem with flat namespaces.

pixeltrix added a commit to rails/rails that referenced this issue Nov 30, 2012
Move the Journey code underneath the ActionDispatch namespace so
that we don't pollute the global namespace with names that may
be used for models.

Fixes rails/journey#49.
pixeltrix added a commit to rails/rails that referenced this issue Dec 19, 2012
Move the Journey code underneath the ActionDispatch namespace so
that we don't pollute the global namespace with names that may
be used for models.

Fixes rails/journey#49.
@pixeltrix
Copy link

Closing this since Journey has now been integrated into Action Dispatch.

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

No branches or pull requests