12 February 2007

public static Valerie getInstance()

A common design pattern is to encapsulate application preferences in a singleton class. The class handles persistence, and any other class which wants to access the preferences can just declare the singleton and access away.

This makes me uneasy. It’s a bit too much like we’ve just thought of a polite new euphemism for global variables. So, my question:

Has anyone encountered a real-world scenario where it was necessary or desirable to have multiple application-preference-encapsulating objects instantiated at the same time?

(This is also my early entry for “nerdiest joke-in-the-title of 2007”.)

© mathew 2017