The Tyranny of .NET Namespaces (cont’d)

A few moments ago I through up a post about when and were to use the namespacing convention for project names inside a Visual Studio solution. I am definitely for naming a project (and the outputted assembly) something which patches the common root within the classes contained within the assembly. So if I had an assembly with the following structure:

  • Company.Product (namespace/assembly root)
    • DomainModel (namespace)
      • Customer (class)
      • Order (class)
      • Opportunity (class)
    • Mailer (namespace)
      • IMailer (interface)
      • SmtpMailer (interface)

I’d probably name the project and assembly Company.Product, if for some reason I split the mailer up from the domain model (a deployment consideration) I’d probably case the two assemblies like this:

  • Company.Product.DomainModel (namespace/assembly root)
    • Customer (class)
    • Order (class)
    • Opportunity (class)

All in the Company.Product.DomainModel assembly, and the mailer as follows:

  • Company.Product.Mailer (namespace/assembly root)
    • IMailer (interface)
    • SmtpMailer (class)

Obviously sitting in the Company.Product.Mailer assembly. There naming your namespaces gets interesting is when you start really plugging into the user facing frameworks. For example, in my earlier post I mentioned that I might name a PowerShell automation library Company.Product.Management.Automation.

I think what I was getting at with that is that it sometimes makes sense to mimic the structure of the .NET framework with some assembly names because it allows people familiar with that technology instantly recognise what might be contained within.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s