views:

229

answers:

2

I run code analysis on a project and I get a warning saying

CA1020 : Microsoft.Design : Consider merging the types defined in {some namespace} with another namespace. {some namespace}

Why do I get this? Is there a negative implication of having too many namespaces?

+7  A: 

I believe the main reason is discoverability and believe that plays a large part in the successful support and maintenance of your code. If it's easier to discover it should be easier to maintain.

Here's the a quote from MSDN.

Namespaces should contain types that are used together in most scenarios. When their applications are mutually exclusive, types should be located in separate namespaces. Careful namespace organization can also be helpful because it increases the discoverability of a feature. By examining the namespace hierarchy, library consumers should be able to locate the types that implement a feature

Kane
+1 for quoting the good advice.
Noufal Ibrahim
+1  A: 

There are no real negative implications at runtime, in terms of increased memory or execution times. Also, namespaces are not like IP addresses, which have a fixed pool and can eventually run out.

Namespaces are basically a naming convention to help you group related things together. The CA error is suggesting that too many small namespaces may make your code harder for other people to use.

IanRae