Identical class names in different namespaces

前端 未结 6 1869
无人共我
无人共我 2021-01-11 13:33

I have two different namespaces, with lots of classes with the same name. I believe some code will make it easier to understand:

namespace Print.Pdl.PostScri         


        
6条回答
  •  悲&欢浪女
    2021-01-11 14:25

    Nolde,

    I don't think you should sacrifice the architecture in favor of readability. I believe its more intuitive if you keep the same class names as this makes it simpler if you are switching from PCL to PostScript and vice-versa.

    If you have to use both classes in the same code file, create an alias for the namespace. It will be very clear to read:

    using Pcl = Print.Pdl.Pcl6.Operators;
    using PostScript = Print.Pdl.PostScript.Operators;
    ...
    // use PCL
    Pcl.BaseOperator.DoSomething();
    // Use PostScript
    PostScript.BaseOperator.DoSomething();
    

    Thanks, Luciano Bargmann

提交回复
热议问题