I understand that a class that consists of nothing but public static member functions is called a Monotype. And certain classes, such as the Integer class in Java/C#, have various static functions implemented. I am also guide of writing kitchen sink utility classes, like InputCleaner.StripHTMLTags() and etc.
Is there a guideline for Monotypes and public static functions?
For example, let say I have a dice class
class Dice
{
public static function RollD100()
{
....
}
}
Should be a Monotype, or a class that has to be instantiated?
I do find a few advantages for classes that have to be instantiated:
- You need an object if you have states or data within the class to keep track of
- You can employ polymorphism, as there don't seem to be static member functions polymorphism (at least in C++, if I remember correctly. Think PHP 5.3 might have that)
Whereas for a monotype, you get
- It functions something like a global function
- No steps required for initialization
Other than those, what other guidelines are there?