Is it enough to have a namespace name that exists at two points in the tree?

This is normal:

namespace Simple.OData { // Common OData functionality } namespace Simple.Data.OData { // The Simple.Data adapter for OData } 

It seems like this might be wrong, but I'm not sure.

+6
source share
6 answers

This is certainly true - consider System.Xml.Linq and System.Linq . I cannot immediately foresee any problems ... but that does not mean that this is necessarily a good idea.

Personally, I prefer Simple.Data.OData over Simple.OData.Data , since I suspect that this is primarily aimed at people who use Simple.Data , but happen to use OData - not people who focus on OData . Again, this is similar to LINQ: System.Xml.Linq is an XML API that is rendered with LINQ; it is not a LINQ "provider" as such.

Basically this is the same problem as "Do I have a converter to convert from type A to type B, do I put it next to type A or type B?" - but with namespaces. My experience is that usually more head scratches come up with the idea of ​​the best thing to do than the problems that can be caused by any approach ...

+7
source

It would be more correct, namespace Simple.OData.Data .

This is because the Data namespace must be grouped with other OData related classes.

If you think along with the lines System.Data , System.Data.SqlClient , then this is largely because they are part of the System.Data.dll assembly and are an integral part of this. My own implementation of IDbCommand classes etc. Lives in the namespace MyNamespace.SubNamespace.AdoWrapper , if that gives you some context.

In your case, Simple.Data presumably does not exist or has a lot in it, unlike System.Data ..

+5
source

Of course, if it is semantically correct. See how many namespaces of objects end in .Design , for example!

+1
source

Yes, it is, but there are some disadvantages.

The namespace is part of the type name. That is, a type named C inside the namespace AB has the value ABC .

When you use the using statement, you simply use the shortcut .

Disadvantages:

I noticed that sometimes Visual Studio can get a little confused, especially when using namespaces such as System and others that exist in the .Net infrastructure ... in such a way that you must enter the full name of the type.

0
source

This may confuse some people, but it should not cause any problems. You probably need to specify a namespace first, but if you type this:

 using Simple.Odata; using Simple.Data.Odata; 

Otherwise, the compiler will not recognize it. There is probably a better framework for the thing you are trying to create, but to answer your question: yes, that's fine if you want.

0
source

The last part should depend on the previous part (s) of the namespace. Your adapter is dependent on Simple.OData, but also with Simple.Data. But since Simple.OData is less general, I would prefer something like:

 using Simple.Data namespace Simple.OData.Adapters { // The Simple.Data adapter for OData } 
0
source

Source: https://habr.com/ru/post/896640/


All Articles