This kind of class is known as a monostate - it is somewhat different from a singleton.
Why use a monostate rather than a singleton? In their original paper on the pattern, Bell & Crawford suggest three reasonns (paraphrased by me):
- More natural access syntax
- singleton lacks a name
- easier to inherit from
I must admit, I don't find any of these particularly compelling. On the other hand, the monostate is definitely no worse than the singleton.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…