Hi first of all thank you so much for your blog about Singleton, it helps me to understand that why it is bad for unit test. One thing I don’t understand is that “Only access Singletons from top-level control structures.”, How it can help us? Suppose I have two activity, in that I am using this singleton. If from one activity I book an appointment then it still remains in booked in next activity also right!,

Second thing,

// Mock a calendar
PatientCalendar bookedCal = createAlwaysBookedCalendar();

What will be the createAlwaysBookedCalendar()? How it will generate bookCal object?

📱 Android Engineer, 📝 Writer, 💻 Open Source Contributor, Techie, IoT, Interactive Projects, ☁ AWS, Google Cloud, Firebase, Python, React.

Love podcasts or audiobooks? Learn on the go with our new app.