Skip to main content
1 of 4
Ewan
  • 79.9k
  • 5
  • 83
  • 179

OK, gona take a run at this.

I did work at one company where they had many classes with the same name but in different class libs.

eg.

  • Domain.Customer
  • Legacy.Customer
  • ServiceX.Customer
  • ViewModel.Customer
  • Database.Customer

Bad design you might say, but you know how these things develop organically, and whats the alternative, rename all the classes to include the namespace? major refactoring of everything?

In any case, there were several places where projects, which referenced all these different libraries needed to use multiple versions of the class.

With the using directly at the top, this was a major pain in the arse, resharper would do odd things to try and make it work, rewriting the using directives on the fly, you would get Customer cant be cast as Customer style errors and not know which type was the correct one.

so, having at least the partial namespace,

var cust = new Domain.Customer

or

public void Purchase(ViewModel.Customer customer)

greatly improved the readability of the code and made it explicit which object you wanted.

It wasn't a coding standard , it wasn't the full namespace and it wasn't applied to all classes as standard.

Ewan
  • 79.9k
  • 5
  • 83
  • 179