Suppose I'm making a new library, Jokes,
with a small API. In the interest of making my API easy to use I put it in the base namespace:
namespace Jokes
--> public interface IJoker
--> string Joke();
--> public static class Jokers
--> public static IJoker NewSlapstickJoker()
--> public static IJoker NewAbsurdJoker()
--> public static IJoker NewCheesyJoker()
The implementations of the Jokers are internal:
--> internal class SlapstickJoker : IJoker
--> internal class AbsurdJoker : IJoker
--> internal class CheesyJoker : IJoker
Now I'm pretty sure the following is a guideline to follow (could someone please verify?):
- Do not access types from subnamespaces from the root namespace. (For example, the types in
System
are ignorant of types inSystem.Drawing
).
Does this guideline apply to internal classes? To avoid polluting my root namespace, I would like to put my internal classes in Jokes.Internal
. This would mean that a type in the Jokes
namespace (Jokers
) would know about types in the subnamespace Jokes.Internal
. Is this ok?