Singleton Pattern - Drawbacks

Drawbacks

This pattern makes unit testing far more difficult, as it introduces global state into an application. It should also be noted that this pattern reduces the potential for parallelism within a program, because access to the singleton in a multi-threaded context must be serialised, e.g., by locking. Advocates of dependency injection would regard this as an anti-pattern, mainly due to its use of private and static methods. Some have suggested ways to break down the singleton pattern using methods such as reflection in languages such as Java or PHP.

Read more about this topic:  Singleton Pattern

Famous quotes containing the word drawbacks:

    France has neither winter nor summer nor morals—apart from these drawbacks it is a fine country.
    Mark Twain [Samuel Langhorne Clemens] (1835–1910)