Is this OK:
namespace Simple.OData
{
// Common OData functionality
}
namespace Simple.Data.OData
{
// The Simple.Data adapter for OData
}
It feels like it might be wrong, but I'm not sure.
Is this OK:
namespace Simple.OData
{
// Common OData functionality
}
namespace Simple.Data.OData
{
// The Simple.Data adapter for OData
}
It feels like it might be wrong, but I'm not sure.
It's certainly valid - consider System.Xml.Linq
and System.Linq
. I can't immediately foresee any problems... but that's not to say it's necessarily a good idea.
Personally I prefer Simple.Data.OData
over Simple.OData.Data
, as I suspect this is primarily aimed at people who are using Simple.Data
, but happen to be using OData - not people who are focused on OData
. Again, this is like LINQ: System.Xml.Linq
is an XML API which plays will with LINQ; it's not a LINQ "provider" as such.
Basically it's the same sort of problem as "I have a converter to convert from type A to type B; do I put it near type A or type B?" - but with namespaces. My experience is that usually more head-scratching goes into thinking of the best thing to do than the problems that would be caused by taking either approach...
More correct would be, namespace Simple.OData.Data
.
This is because the Data
namespace should be grouped with the other classes relating to OData
.
If you're thinking along with lines of System.Data
, System.Data.SqlClient
then it's pretty much because they are a part of the System.Data.dll
assembly, and are an integrated part of it. My own implementation of the IDbCommand
etc classes live in MyNamespace.SubNamespace.AdoWrapper
namespace, if that gives you some context.
In your case, Simple.Data
presumably doesn't exist or have much in it, unlike System.Data
..
Sure it is, if it's semantically correct. Look at how many framework namespaces end in .Design
, for example!
Yes, it is, but there are some drawbacks.
The namespace is part of the type name.
That is, a type named C
inside namespace A.B
, is actualy named A.B.C
.
When you use the using
statement, then you are just using a kind of shortcut.
Drawbacks:
I have noticed that sometimes Visual Studio may become little confused, specialy when using namespaces such as System
, and others that exist in the .Net framework... in such a way that you must enter the full name of the type.
It might be confusing to some people, but it should not cause any problems. You'll probably need to preprend the namespace though if you type this:
using Simple.Odata;
using Simple.Data.Odata;
Otherwise the compile won't recognise it. There's probably a better structure possible for the thing you're trying to create, but to anwser your question : yes it is ok to do it if you want.
The last part should be dependant on previous part(s) of the namespace. Your adapter has a dependancy with Simple.OData but also with Simple.Data. But since Simple.OData is less generic I'd prefer something like:
using Simple.Data
namespace Simple.OData.Adapters
{
// The Simple.Data adapter for OData
}