Namespaces are not a packaging mechanism. In Java, unfortunately, they are. The reason why this is not good is that you end up making everything public, even though most of the time the “friendly” would be just fine. If the two concepts were separate*, you’d be able to make a logical “package”, a module, a lump of classes that can all belong to sub-hierarchies of namespaces but many can be visible only internally to the package while just a few classes end up being exported.
Another annoying thing is insisting on structuring your files on the disk in the same way. So if I change the namespace (or “package”) of a type, I end up moving the file on the disk. Assuming you are using a SCC this means you have to move the file in the repository too. If your SCC does not allow easy moving of the file (preserving change history!) or if your organization has a dedicated SCC administrator you are in a world of pain.
The name “package” is misleading too – you’d actually package the classes in JAR files in most of the cases.
*This is exactly how it is in the .NET.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5