If I’m developing a script for the Asset Store, and it has a C# class named
Item (to use a dummy example), and since Unity doesn’t support namespaces, this class name could eventually collide with a class name defined by the user of the asset, or even another Asset Store script included in the same project, right?
If so, should I always name top-level classes using a vendor prefix that makes it more unique (like, e.g.,
mycompanyItem)? Or what are the conventions and solutions to avoid name clashes with other Asset Store or user scripts?
Every programmer and company has their own naming conventions. My company, and I know a lot of other companies as well, often prefix our classes with our abbreviation.
For example, a recent environment manager rewrite that I performed was named BLSEnvironmentManager as to not conflict with HVSEnvironmentManager. This will also group all of your classes together in whatever auto-completion the user’s IDE is.
Unity 4 has limited support for namespaces, as explored in this Answer. I’ve personally used namespaces in my U4 project and everything has worked fine.