How to avoid class name and namespace conflict?

核能气质少年 提交于 2019-12-10 10:42:49

问题


Sometimes I have need to call namespace and class the same. For example, SomeProject.Compiler namespace, containing lots of compiler-related stuff and the main entry point class Compiler. But naming namespace and class name the same is not recommended, as it creates ambiguity and misleads compiler.
Is there any idea, how to name them better?


回答1:


It is always possible to give general namespace name, which describes all its members. For example, CompilerServices instead of compiler.




回答2:


Some books say you should write the domain of your company (in the reverse order) before the name of namespace.

Something like com.company.www.compiler



来源:https://stackoverflow.com/questions/4547254/how-to-avoid-class-name-and-namespace-conflict

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!