Avoiding Conflicting Namespace and Class Names in C#

cdomain-driven-designnamespacenaming

Say I am developing a Calculator application. It has one class called: Calculator. Therefore my namespace structure would look like this:

MyCompany.Calculator.Core.Calculator

Unfortunately, this is not right because the same name should not be used for a namespace and a type in it. This is thoroughly explained in this other SO question. One of the answer to that question suggests to solve the ambiguity by using an Util suffix for the namespace, which would then look like this:

MyCompany.CalculatorUtil.Core.Calculator

This solves the naming ambiguity in the programming language. However, this kind of naming is in contradiction with good DDD naming practices: because Util seems to be a "weasel word" according to this article on naming in the ubiquitous language and these should be avoided.

What is the best way to avoid a conflict here in the case of a Calculator?

The application I am developing is much more complex than a simple calculator, however the principle still stands.

Best Answer

Is the name of your application 'Calculator'? if it is you may find that that name has already been used.

I would also advise you NOT to use myCompany as part of the namespace. I know its a standard way but company names change.

Just have:

MyApplicationsRealName.App
MyApplicationsRealName.LibraryName.ClassName
Related Topic