David Mertz firstname.lastname@example.org writes:
Why is this a misuse? Classes are largely just namespaces to start with, and if you want to use them solely for that purpose, it's all there for you.
I think it's a misuse of the semantic meaning of classes to use them as pure namespaces. The semantic intent conveyed by defining a class is that you're defining a class *of objects*, and therefore that the class is intended to be instantiated.
The programmer reading a class definition is receiving a strong signal that there will be objects of this class in the program. To have a class and not instantiate it, merely to have a namespace, is at least misleading the reader of that code.
To do this is not an error. But it is IMO a code smell. If you're defining a class and using it only as a namespace, your design is likely poor and you need to re-think it.
In this case, I think Tennessee's intent is much better met using modules; those *are* semantically namespace singletons, matching the intent here and therefore much better at communicating that intent. I see no justification given here for avoiding modules if this is what's needed.