S
Sender
what's the difference b/w namespace and a class
Sender said:what's the difference b/w namespace and a class
Scott M. said:One important aspect of namespaces is that they help to avoid class naming
collisions.
If you and I both work for the same company, but in different departments, I
might make a class called customer and you might also make a class called
customer. Now, my customer and your customer may have completely separate
uses and completely separate meanings, but the name we both chose happens to
be the same.
Now if a 3rd person in our company needs a customer class, should they use
yours or mine? How would that 3rd person know which is which?
By storing classes in namespaces, we can eliminate this problem. My class
could be stored in my departments namespace and so could yours.
AcmeCompany.HumanResources.Customer
...and...
AcmeCompany.Marketing.Customer
"AcmeCompany.HumanResources" and "AcmeCompany.Marketing" are the namespaces
and "Customer" is the actual class placed into the namespace.
Now that 3rd person in our company would have a better idea of which
customer class to use!