Advice on class library namespaces

I have finished writing a set of classes and utilities for those who want to use MVC 2.0, LinqToSql and StructureMap to write their small to medium applications. Currently, there are a total of 34 files in it. Since it doesn’t seem like too many, I simply left them all in the root namespace for simplicities sake. However, they don’t all serve the same area. For example, there’s a fluent mapping interface for Linq2Sql, a complete specification implementation (generics and non - And, Or and Not subclassess as well), some extension methods, some interfaces to help with validation and getting around concurrency issues and so forth, and a few other things. If I split them up though, some of the sub-namespaces will only have one thing in them.

Should I split this up or leave it as-is?

Thanks!

I’m still having some trouble understanding exactly what the structure is. Let me just say that my first and guiding principle is always “Stay true to your abstractions.” Since the semantics of your code (including the namespaces) is how your make your abstractions “real” and self-documenting they’re critical, so I wouldn’t be afraid to chop things up into namespaces that have only a few classes in them. If you have some odd strays that you don’t like, you can collect them together into something like a “Helper” / “Misc” namespace.

That said, the purpose of a namespace is to collect related classes together so that the abstractions make your life easier. Instead of worrying about all those classes when you’re working with your app, you only have to worry about a lot fewer namespaces. So putting 34 files with 100 classes into 30-40 namespaces is not going to make your life easier. Namespaces are high level abstractions so don’t be afraid to get a little general in the naming conventions. e.g. I have cryptography classes, authentication classes, and session management classes in a group of files for my application. However, I tuck them all into my Ec.Security namespace and keep all those .cs files in my Security folder inside the EC folder that’s inside App_Code.

Hm. Ok, to clarify, for anybody else who may have been just as confused at my description, let me offer the following example, directly from the class library:

First and foremost, the library was to be a fluent mapper for Linq2Sql, so I have the following:

FluentEngine.AssociationMap
FluentEngine.AutoSyncEnum
FluentEngine.ClassMap
FluentEngine.ColumnMap
FluentEngine.FluentManager
FluentEngine.FluentSession
FluentEngine.IAssociationMap
FluentEngine.IColumnMap
FluentEngine.IMap
FluentEngine.ITypeMap
FluentEngine.Map
FluentEngine.TypeMap
FluentEngine.UpdateCheckEnum

Second, I wanted to bundle in a base repository so I wouldn’t have to keep adding it to my actuall apps, so I added in the following:

FluentEngine.IRepository
FluentEngine.Repository

Third, I needed an interface that specilized repositories could use to aide in overcoming concurrency issues, so I added:

FluentEngine.ITransferService

Next, I decided to add some other common things from my standard list of things I do in my mvc apps, so I added the following:

FluentEngine.AndSpecification
FluentEngine.ISpecification
FluentEngine.NotSpecification
FluentEngine.OrSpecification
FluentEngine.Specification

Because I validate in services, I also added:

FluentEngine.IValidationError
FluentEngine.IValidationService
FluentEngine.ValidationError

Lastly, I added some extension method classes and a controller factory for use with StructureMap.

Right now, as you can see, everything is one namespace. I rather like the idea of being able to simply add “using FluentEngine” and have access to everything I need. On the other hand, something like the following might be order…

FluentEngine.Concurrency
FluentEngine.Configuration
FluentEngine.Extension
FluentEngine.Mapping
FluentEngine.Persistence
FluentEngine.Specification
FluentEngine.Validation

Or should I rip out things that aren’t actually part of the fluent engine itself, and put them into a separate library?

FluentEngine.Configuration
FluentEngine.Mapping
FluentEngine.Persistence

-plus-

FluentEngine.Extras.Concurrency
FluentEngine.Extras.Extension
FluentEngine.Extras.Specification
FluentEngine.Extras.Validation

Is that more clear? Anyway, I’d like a few more comments before I decide how to wrap this up.

Thanks.