[development] module names and namespaces

Larry Garfield larry at garfieldtech.com
Sat Oct 16 17:29:58 UTC 2010


This is a well-known problem that comes up less often than most fear, but does 
come up. :-)  In this case, it sounds like fb_social is Doing It Wrong(tm).  

There's been periodic talk of changing the way hooks work to avoid this 
problem, although that would not help with variables.  The leading contenders 
for hooks are to switch to _hook_ as a separator rather than just _, or to use 
PHP 5.3 namespaces.  There are open issues for both targeted at Drupal 8.  
Personally I lean toward the namespaces approach but it's still too early to 
know what we're going to do there, as there are a LOT of issues to consider.

On Saturday, October 16, 2010 11:34:05 am David Cohen wrote:
> Hey, I'm wondering what the community thinks about this...
> 
> I feel that if I have modules/foo/foo.module checked into drupal.org CVS
> and drupal.org/project/foo, then this module stakes a claim to the
> foo_... namespace.  That is, I can name my functions foo_whatever
> without worrying that some other module out there already defines the
> same function.  Similarly, I can name my variables foo_whatever,
> database tables, and so on.
> 
> Now, let's say someone else checks in a module called foo_bar.  And say
> both modules define the same function, variable or other namespace
> collision.  What then?  Is that a bug, and if so which module is
> responsible for fixing it?
> 
> If you want a concrete example, both fb.module and fb_social.module
> define variables starting with "fb_", and specifically I wonder how to
> respond to http://drupal.org/node/943462.
> 
> I don't want to start a flame war. I'm curious if there is community
> consensus or official policy.  Personally I think its a bad idea to name
> any module with an underscore.  That is, drupal.org/project/foo_bar
> should instead be drupal.org/project/foobar, as this avoids any
> confusion.
> 
> -Dave


More information about the development mailing list