Question : Where would you choose a Singleton over a Static class?
I always expect two words to answer this question
- State : Static objects are not well-suited for good state management (think scalability).
- Weight : Don’t want too many heavy static objects floating in memory (think performance).
That would basically answer this question, but to be more fair and give a good explanation, I found a good article here [Link].
As a part of my job, I interview potential candidates for jobs, and one of the standard questions I ask is ‘What is the difference between a class and a structure?’, and I sometimes am surprised with the kind of answers I get.
So, I decided, I should get some of these proper QnA’s for interview questions, and post them as a series.
||Heap (requires cleanup by GC)
||> 16 bytes
||< 16 bytes
|Default protection level
Misc references :