Andreas wrote:
Zach Dennis wrote:

Whats the status (if any) on namespace pollution in rails? Are things moving towards a friendlier namespace or no?

If not, I would like to open it up for discussion and perhaps suggest some idea to fix this,


Did you read http://wrath.rubyonrails.org/pipermail/rails-core/2005-December/000458.html?

That was just the other day! I just now read it. I like the idea you're working towards. I don't have much experience with Engines so I'll only add my 2 cents on the problem area I am familiar with. Model namespaces.

> If you want the WikiEngine and the BooksEngine to use the same "User"
> model:
>   WikiEngine::User = BooksEngine::User = MyUserModel

Models (even in the above example) are assummed to be defined in the toplevel, and this is how Rails convention as worked up to this point. I think this is a huge problem because of the varying names of database tables.

For example when following convention you cannot use a table named "logs", because it's model name is ::Log. If you develop with webrick this is a problem because webrick defines a ::Log. Table names can range from obscured words like "YMCRRPZS" to more traditional names like "logs", "files", "users" or "people".

Because the range of names can be so vast and since not every database can be altered just to work with Rails, model names should be moved inside of another namespace. Perhaps models are put inside of a Rails::Models namespace by default. If users want to 'include Rails::Models' at the toplevel they can have that flexibility, but it allows the problem to be solved where namespaces would be clashed for model names.

The future problem of this is that it's going to limit the extendability of Rails itself, because if you have models polluting toplevel namespace and a new stdlib class/module, core class/module or new third-party library is released, and there is a namespace clash, people will have to choose, modify your rails application to use a different model name or don't include the latest feature from another party (whether's it's ruby core, stdlib or 3rd party lib).

Ok, enough of my rant.

So if this goes along with what Andreas is saying then I think it is a problem that needs to be solved as Andreas has already brought up.

Zach
_______________________________________________
Rails-core mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to