I am frequently having naming conflicts between a namespace and a class within that namespace and would like to know a best practice for handling this when it seems to make sense to use these names in the first place, besides adding random prefixes.
It seemed to make sense to have a Models.Technology namespace, with dozens of technology classes (ie. Weapon, Agricultural, Recycling technologies) and some related interfaces in it. I also decided to have a Technology abstract class, in the Technology namespace, from which all technologies derive.
However, this is forcing me to use code like this:
public Technology.Technology research(Technology.Technology tech) {...}
and likewise:
public Building.Building build(int count) {...}
By the way I did not name my namespace Technologies since I use that term elsewhere as a wrapper for a list of available technologies...
Without more precise indications on when you encounter this problem it's hard to give you some general advice.
But I'm gonna suppose you have this problem when you have a base class in your namespace, with others classes inheriting from it. If that's the case you could call your class BaseTechnology (base class) or AbstractBuilding (abstract class) or IAnimal (interface). This even give you more clarity since you specify in the name of your type something important about it.
Well, whether your name your namespaces like that nsMyNamespace or you name you class cMyClasse. I'm personnaly in favor of naming the namespace, because it's not something you use a lot in code.
You can also use TechnologyBase or AbstractTechnology for naming your main abstract class that conflict with the name of your namespace, which is what i recommend to keep the most logical naming convention.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With