design - How to answer the interview question: What is a singleton and how would you use one? -
I've read the question on the SO. Talk about singleton and talk about just one hour long technical technology. As far as I can tell, the common consensus in the o o world is that singleton is more of an anti-pattern rather than a useful design method.
He said, I am interviewing these days and the question comes up a lot - what is a singleton, and how will you use it?
What is the best way to answer this question? Should I just describe the design pattern and then say that I have accepted the acceptable use of logging, and it is often misused for the global situation?
intriguing. There are a lot of people who believe that singletons are essentially an anti-pattern as you said (I am included), but many people also feel that it is only an OOP-acceptable way to do globals.
> If the interviewer is in that camp, yes, I think that is wrong, but it will not be the best to say during the interview. ;)So I will probably try to be neutral and stick to the facts. If you do not know which camp falls in your camp, then focus on the undisputed facts. What does a singleton do? And to demonstrate the use, stay in some cases where most people can agree that singletons are an acceptable answer. Or explain your experience (because people can not disagree with it).
But are you a "for" or "against" songwriter, an interview is probably not the right time to dispute for that reason. ;)
Comments
Post a Comment