One can often see class names carrying a reference to the namespace to which they belong. One of the most popular examples is the .NET ‘Xml’ namespace where every single class defined in it is prefixed with the ‘Xml’ tag.
This has always seemed pretty redundant to me, but recently I’ve realized that in some cases it could be useful… but still redundant.
I’d like to know how people actually deal with this issue.
Thanks.
I take the ‘when it is appropriate’ approach. The idea is that you want to name your classes using the name that makes the most sense. In some cases it does mean that the class name is somewhat redundant with the namespace, but keep in mind that the namespaces aren’t generally seen as part of the class name in the code other than as part of a using directive.
The namespaces are used to logically group related classes, etc. together to help the developer find the correct classes and help minimize the chance of name collisions.