How to avoid the same name of namespace and class in C#?

Viewed 3212

I knew it is recommended to use different names in class and namespace, but sometimes it is hard to achieve it. It is easier said than done. They never give us a solution when we need to use the same name because of a certain case.

For example, I need a namespace in which to locate all the classes about configuration, so the namespace is named ABC.Configuration. I don't think there is anything wrong with this name.

And under the namespace I need a class to store the configuration, so its name will also be Configuration. Reasonable, don't you think?

Besides I have some other classes such as ConfigurationBuilder, ConfigurationManager, etc, under the namespace.

What's more in Java, the package name we use "camelCase", and the class name we use "PascalCase". So because of the case of naming, there is no problem.

So how to name the classes in this scenario in C#?


Thank you very much. If I use Configuration.Configuration, I need to write more only because of naming while others are just ConfigurationManager without the namespace. It's a little bit mess.

The idea to use ConfigurationStore is a good one, thank you. I think the solution to name a class is to identify the usage clearly in the name and add another word. But in my project, I need to use the Configuration somewhere, if I write ConfigurationStore.Path to read the configuration, it looks strange. Maybe I can use a interface like IConfiguration to avoid the naming problem

4 Answers
Related