Should I put my interface definition in same namespace as its implementation
This is particular related to c# however I guess it can cover any language.
It's typical in Java to have the two in the same package. The one exception I can think of might be a DAO interface in a package persistence and different implementations in subpackages under that (e.g. jdbc, hibernate, jdo, etc.)
You can think of a public interface as being the API that's exposed from the package. I can see where implementation classes might be package private, preventing users from accessing the implementation via anything other than the interface. Public factory methods would have to be provided to grant access.
It's probably better to use the established conventions of the .NET predefined classes. For example, looking in the System.Collections.Generic
namespace we can see that both IDictionary
and Dictionary
are there. So probably putting them in the same namespace is the best idea.
Also, since both the interface and the implementation most likely serve the same purpose, it's better to group them in the same namespace.