Living Singleton
Harshita Chandra25 Apr 2015
What do we have:
A singleton class where we can initialise a string pattern. We then call a singleton function that doubles the pattern before printing it on console.
The Problem:
Instead of a string pattern, the console prints (null)
.
Concepts:
Who hasn’t faced a question about design patterns in an interview? This problem can be followed after a general enquiry about the common design patterns. As most people have the singleton code memorised, we can ask the candidate to write the alternate code snippet for dispatch_once
and then strike up a discussion about GCD functions.