From: Leslie Viljoen Date: 2005-11-07T16:13:42+09:00 Subject: Re: Namespace pollution in Rails Trans wrote: >>I agree with what you are saying, in fact I think libraries that >>do this should be removed - and that is what they have done >>in response to my requests at Textdrive. Strangely, I installed >>the latest version of Nitro and Glue and both irb and the >>Rails console environments were inaffected. It must have been >>an older version of Glue, but it still beats me how this came about. >>Irb showed no pollution, only when running a Rails app did there >>suddenly appear a loaded Glue module. >> >>This is why I am so curious about it - how did Glue get itself loaded? >> >> > >Unfortuately require doesn't record absolute paths (fixed in 1.9) and >Gems can have subtle effects on how things get required. So between the >two there's a name clash somewhere. > >That seems to be a bad tendency of such "full-stack" solutions. They >tend to think they own the entire relam of namespaces. I recall once >someone suggesting Ruby use variable's for module loads rather then >static constants. That would have helped, but such is life. Presently >I'm working with George to help seal up issues on the Glue side as time >permits. > > From what I have seen, these functions are in the top level namespace as a convenience, and one we can't live without because in Rails, if I had to type <%= h::Base::ActiveSupport myfunction %> for every field I would go crzay. > > >>I'd like to be able to circumvent such things in future, it is >>impossible to code around every possible class people dream up >>and Glue even modified the default String class! >> >> > >Well, thats' not neccessarily bad. As long as one's only adding methods >(and documenting them!) it should be okay. The serious problems araise >when one changes pre-established behaviors. That's why there is such a >clamor for namespace selectors these days. > >T. > > That's not bad as long as you have the option to not include a module that does this. If not, your classes get heavier and heavier as they get larger and larger, and if you want to add to them yourself you find yourself increasingly unable to find a name that remotely describes the functionality you are adding.