I´m programming a Class which acts as a Singleton. I was wondering, does it make sense to have non-static properties for this class?
Pseudocode example:
class Foo extends MySingletonClass {
private static string bar;
private string baz;
/* more code here */
}
It's not wrong to have static properties, but it's redundant in a singleton.
Also, if you have static properties, and later you need to change the class to not be a singleton no more, you'll need to change the properties either (as every code that access it). So I recommend you not to mark as static, unless really needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With