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.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store