Naming Namespaces

November 27th, 2008

The naming guidelines on MSDN say to make namespaces plural where it is semantically appropriate.  For example, a namespace like “Project.Core.Widget” just looks wrong (to me).  For one thing, what if you wanted to have a class in that namespace called ‘Widget’?   For another, if I have a namespace then I probably intend there to be more than one class in it.  So, “Project.Core.Widgets” seems more natural to me – that’s where the collection of widgets is.

But, in the same project, I’ve also got two other namespaces “Project.Core.Model” and “Project.Web.View” – on the surface, this is inconsistent with the plural convention.  But (again, in my opinion) “Models” and “Views” seems kind of…weird.

But here’s my rationalization for this inconsistency: there aren’t multiple Models in that namespace.  The classes that are in the Model namespace all are components of The Model.  Same with the classes in View – they are parts that operate on A View (not The Only View, but you get where I’m going with this).

So, we’ve kept the same semantic meaning of a namespace – consisting of Parts of a Whole.  Just with singular nouns instead of plural.  Is that sensible, or just a RetCon to explain away something that “looks right” (or wrong)?

Tony Rasa Esoterica

Comments are closed.