Yes, there could be a performance difference. If you were, for example, to write a class for a Logger, and in the entire runtime of the application you never logged anything, then you wouldn't have needed to initialize the logger. If you wrote this class as static
, then you would initialize it at the beginning of the program regardless of whether you use it. If you were to create it as a singleton, you could perform lazy initialization, which solves this issue.
In terms of the "Preferred Way," from what I've heard, it is preferred to implement it as a Singleton or similar if your object has state, and static if otherwise. This is to improve testability, because testing a static
object with state is a pain in the butt, and it isn't reliable. But that is for a different question.
In your case, with fields, the answer is definitely to go with a singleton unless you have strong reason to do otherwise.