views:

46

answers:

1

Hypothetically, if I have:

Contoso.App.People.SecurityGuard : Contoso.App.People.Person

And I then build this class and ship it as a core lib. If I then consume this library in, say, a mobile client app and make a:

NightDeskGuard : Contoso.App.People.SecurityGuard

In which namespace would the new class go?

Contoso.App.Mobile.People // a new mobile app specific namespace

Or:

Contoso.App.People // in with the rest

Or:

Contoso.App.People.Mobile // best of both worlds?

This is arguably a subjective question, but with the voting system here I would be happy to see how people go about this.

The .NET Framework itself does a mix of all three. I don't think there's a right answer per se, but it'd be nice to follow consensus and expectation.

Thanks, Luke

+3  A: 

Don't confuse namespaces with deployment units (DLL's). They are different things.

Namespaces are a way to logically group code. They can span many deployment units (DLL's), which is also how the framework does it (System.Web lives in many DLL's).

DLL's are a physical deployment unit.

I would use the Contoso.App.People Namespace, but compile that to a Contoso.App.Mobile.dll.

That way, when coding, the People will stay together, but when deploying, the mobile DLL will only go to mobile clients.

Oded
Many thanks for your answer, this really helps. I will leave the question open to harvest more answers, and won't taint it with my own opinion just yet...
Luke Puplett
@Oded - I agree and am reassured by your answer. I once read "one namespace per assembly" and that's what I had been doing, but that approach doesn't sit well with the notion of deployment units - you hit the nail on the head.
Luke Puplett