3

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 */

}
The Student
  • 27,520
  • 68
  • 161
  • 264
Yeroon
  • 3,223
  • 2
  • 22
  • 29

1 Answers1

4

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.

The Student
  • 27,520
  • 68
  • 161
  • 264