- Posted by liammclennan on July 27, 2011
I tweeted
there are good reasons to have different hierarchies for directories and namespaces. Resharper overruled.
this post adds a brief explanation of what the hell I was talking about.
By default, Resharper encourages us to use a directory hierarchy that matches our namespace hierarchy. Most of the time this is a sensible starting point, but there are some occassions when it is not ideal.
In my current project we group classes by function. Elsewhere, we have other classes that are named by function. The purpose of namespaces is to prevent name collision, but in our case if the namespaces match the directories it actually causes a name collision between the namespace and the identically named class.
Since there is no reason why the classes grouped (in directories) by function need to be in separate namespaces we put them all in the same namespace, thus resolving the name collision.