C # naming conventions in namespaces

At work, they were quite complicated with their namespace names (until my time). A typical namespace might be

CompanyName.SubCompanyName.DepartmentName.ProjectName.UniqueProjectName.ProjectName.FilteredProjectName

Sorry, I'm not joking. The problem is that, despite some clarity as to where the projects live, it is so noisy; I want to cut it.

I want to use the using keyword (in relation to declaring which namespaces should be used), and then equals the character to use the namespace alias. Now the problem is turning into an ambiguity between the namespace declaration and the class property. for instance

 Project.Message 

In our case, we have no indication if Project is the name of a static class, namespace or the name of an object that has already been initialized (although the word this. Would help clarify it).

So, with this background, my question is about naming conventions. It would be wise for me to use Hungarian-style naming conventions (which, as I know, are now considered pretty outdated), so I could do something like

using nsProject = CompanyName.SubCompanyName.DepartmentName.ProjectName.UniqueProjectName.ProjectName.FilteredProjectName

Note that I prefix it with ns (namespace). Therefore, if the code looks like one of the following, there is at least some clarity:

 this.Project.Message nsProject.Message Project.Message 

The 3 examples above are pretty clear: the first is already declared in the project, the second is the namespace, and the third is probably a call to the static method.

Does anyone have any comments about this approach; am I reinventing the wheel (are there any recommendations on the spot), or does anyone have a different opinion on what can be done?

EDIT

Another reason to use Alias ​​is because the current namespaces do not match (or have any meaning in some places) in the folder structure. Therefore, I not only want to ensure clarity between what type of object / namespace is used, but my alias will also be a guide to the location of the folder. I know this probably reads like hacking, etc., but (according to the comments in this post) this is the first step of many.

+4
source share
1 answer

I would not know any β€œofficial” recommendations, but whenever I call a namespace, I usually use the abbreviation for Company and Project. This will result in (using your example):

 this.Project.Message.Send(); CompanyProject.Message.Send(); Project.Message.Send(); 

I prefer postfixing above Hungarian btw (subjective I know).

+2
source

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


All Articles