You can practically call your namespace anything you want. Different languages seem to have their own conventions, but the reverse DNS style is what I like the most.
The idea of a namespace is to encapsulate your code, hide it behind folders unique to you. Some of the big libraries will ignore the reverse DNS rule. In JavaScript you’ll find their seems to be no rule at all.
Reverse DNS
Your DNS is unique to you, so it is a great idea to create your namespace using it.
If my domain is www.betweenthebraces.com you drop the www and flip the domain name to create your namespace.
My namespace is com.betweenthebraces.
From this point you can add your project name and any other packages you need.
For example: com.betweenthebraces.myapp.Viewport might be the location of my main class for a mobile application.
Glad to read this blog! Keep it going!
Hi Robin,> I do HATE the Java style of com.company.namespace.You are not alone. I wonder if it did attarct enough Java developers or helped enough with migration from Java, and so if it was worth it.In my everyday use, 90% of the time I’m dealing with members of a class, and so the variable that holds the pointer to the object instance is all that is needed for proper qualification.Name collisions, if any, may occur at the very top level. 99.9999% of the time, what I import/include/use don’t have any collisions. Libraries/components I use, use prefixes if their top level classes have somewhat generic names. But this is, again, most of the time redundant because even if they use generic names, I wouldn’t be normally using such two components from a single file.I usually define an object type with t or o prefix. Then I define a pointer to that type with p prefix, which will be the type I will actually use when creating the object instance.My point is that namespaces are abstract implementation details that does not help the coder to code better. I import/use/include this file/library is what the coder should know and care about. Thinking in namespaces doesn’t improve anything. If there is a name collision then you should use the qualified, longer name. That’s it. That’s simple. Why should you deal with abstract entities called namespaces, when it does not return back any benefits?If *all* your code was in a single file, you wouldn’t be able to declare two different things with the same name and there wouldn’t be any namespaces (the only namespace would be like air you live in and don’t know about) [Of course I'm assuming you are not using namespaces as access specifiers, creating namespaces out of nowhere]. That’s the simplest case, and that’s IMO is the goal simplicity level. How much should you be inconvenienced because you have your code in separate files and name collisions are allowed?Best,Burak