So, I’m writing a module for connecting to external account providers (Twitter, Facebook etc) and I have a superclass that is useless on its own, but contains generic methods that need to be invoked by the subclasses for persisting auth tokens, getting auth tokens and deauthorizing the provider. My question is, is there a way to make it uninstantiable or should I follow the consenting adults rule and just let anyone who uses it make mistakes as they see fit? Other than a docstring is there a good way to denote that someone shouldn’t use this superclass on its own?
So, I’m writing a module for connecting to external account providers (Twitter, Facebook etc)
Share
I’m seconding Sven Marnach’s edit: I think you should follow the “consenting adults” rule and mention in the docstring that the class is not meant to be instantiated.
The key phrase in your question is “I have a superclass that is useless on its own.” It won’t invoke cthulhu when instantiated; it won’t cause some kind of catastrophic, hard-to-debug failure somewhere else in your program; it will just be a minor waste of time. That’s not worth crippling the class for, I think.