views:

42

answers:

2

Hi:

I'm setting up a new app, with a Repository layer/assembly, a Services layer/assembly, and a UI assembly.

So I end up with namespaces such as:

App.UI App.Biz.Services App.Data.Repositories

And then I have enums for the args that are used by all 3 layers. Only place that makes sense is to put them in the Cross cutting assembly. (define them in Data layer too low, as UI should have no direct ref to them, defined in Services, too high for Repository layer, which shouldn't be referencing upwards).

But...which namespace in Common? Namespaces should mostly be used to define concerns, rather than Type... I've always used something like:

namespace App.Common.Enums {...} 

but it's always felt a bit of a hack that works for me, but not well in a large org where everybody is generating Enums, and if we put them all in Enums folder it's going to make the code folder harder to understand later.

Any suggestions?

A: 

What I've been doing is creating a Contracts assembly and all the stuff in there is in the root application namespace. I'd put common stuff, like Enums that everything needs access to, in that Contracts DLL.

Another good use for that spot is interfaces.

Scott Whitlock
+2  A: 

I usually recommend a dedicated assembly for shared enums, interfaces, and value objects. App.Interop or App.Shared or App.Data.Values would be my namespace recommendations.

Sam
Thanks -- I think that mirrors somewhat what I'm already doing (although I use Common rather than Shared, and see the Values are simply Shared and not Data, since they are are used on all layers:XAct.Common assembly containingXAct.Common.EnumsXAct.Common.Entities (for Interfaces only-- not POCOs or other -- of both both Entities and ValueObjects...can't be bothered dealing with a XAct.Common.Entities.ValueObjects)XAct.Common.ExceptionsXAct.Services -- for interfaces of ServicesXAct.Data.Repositories -- for interfaces of Repositories.Don't do enough Interop to know about that part.
Ciel
woops on the formatting...
Ciel

related questions