Collision of names between class and namespace

7

Is it wrong, bad practice or can I have problems with class equal to namespace ?

Example:

namespace Cielo
{
 public class Cielo
    {
    }
}

It has worked, in some places it gets a bit strange to call Cielo.Cielo.etc .

Should I change the class, for example, to CieloService ? or something like that?

    
asked by anonymous 29.04.2016 / 20:08

2 answers

9

Power, can, but not recommended. It gets confusing. There is an official recommendation.

There is a Eric Lippert article on this.

The ideal is to name things as they are. Is the class a Heaven? Or is it a specific Service from Heaven?

Namespace is from Cielo, right?

Have you understood how to name?

    
29.04.2016 / 20:22
4

None of the options.

The namespace serves to give context to the components you are using. It is only useful to the developer.

Having a class name with the same namespace name will generate some confusion, because sometimes you will not be able to use using normally , it will always have to be explicit: var cielo = new Cielo.Cielo(); .

At last, a matter of taste. I recommend that if you do, avoid doing this, like the example you gave of CieloService or CieloClient , I do not know.

But it's not wrong, and I've never read anything and I do not see how bad practice .

    
29.04.2016 / 20:19