Namespaces in .NET / C#
-
Hi everyone! I had a little argument with a colleague about namespaces. He is affirming, that one should use namespaces as less as possible. In my opinion, namespaces not only exist for controlling "the scope of class and method names in larger programming projects" (MSDN quote), but also for somehow organizing my classes in order to have some functional grouping. Now my question is: How do you use namespaces personally? Only one or two per project, or one for each little functional group? Is there any "best practice" you follow? Thank you, Phil
I won’t not use no double negatives.
-
Hi everyone! I had a little argument with a colleague about namespaces. He is affirming, that one should use namespaces as less as possible. In my opinion, namespaces not only exist for controlling "the scope of class and method names in larger programming projects" (MSDN quote), but also for somehow organizing my classes in order to have some functional grouping. Now my question is: How do you use namespaces personally? Only one or two per project, or one for each little functional group? Is there any "best practice" you follow? Thank you, Phil
I won’t not use no double negatives.
Philip F. wrote:
How do you use namespaces perso
Typically I create a namespace for each group of classes that are related in functionality (for example for entities or UI etc..) so yes, I do use quite a lot namespaces.
Philip F. wrote:
one for each little functional group
This depends on the definition of little, but I wouldn't use namespace for a very small set of classes (like two or three) unless there's a very good reason. Typically in my projects we have 10-100 classes per namespace.
The need to optimize rises from a bad design.My articles[^]
-
Hi everyone! I had a little argument with a colleague about namespaces. He is affirming, that one should use namespaces as less as possible. In my opinion, namespaces not only exist for controlling "the scope of class and method names in larger programming projects" (MSDN quote), but also for somehow organizing my classes in order to have some functional grouping. Now my question is: How do you use namespaces personally? Only one or two per project, or one for each little functional group? Is there any "best practice" you follow? Thank you, Phil
I won’t not use no double negatives.
Philip F. wrote:
He is affirming, that one should use namespaces as less as possible.
That's not true. Namespaces helps to organize the code. It is very useful in practice. If there was no namespace concept, programmers will run out of names for the methods and variables.
Philip F. wrote:
How do you use namespaces personally?
I use namespaces extensively. Here[^] is a discussion of namespaces and folder structure which you may be interested. :)
Navaneeth How to use google | Ask smart questions
-
Hi everyone! I had a little argument with a colleague about namespaces. He is affirming, that one should use namespaces as less as possible. In my opinion, namespaces not only exist for controlling "the scope of class and method names in larger programming projects" (MSDN quote), but also for somehow organizing my classes in order to have some functional grouping. Now my question is: How do you use namespaces personally? Only one or two per project, or one for each little functional group? Is there any "best practice" you follow? Thank you, Phil
I won’t not use no double negatives.