From c71d715a656b0137449c68368a9a484ab1e0cf14 Mon Sep 17 00:00:00 2001 From: Dominik Liebler Date: Tue, 3 Sep 2013 14:52:42 +0200 Subject: [PATCH] mark Singleton as an anti-pattern (#31) --- Multiton/Multiton.php | 4 ++++ Singleton/Singleton.php | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Multiton/Multiton.php b/Multiton/Multiton.php index 4327a0e..74f9dcd 100644 --- a/Multiton/Multiton.php +++ b/Multiton/Multiton.php @@ -5,6 +5,10 @@ namespace DesignPatterns; /** * Multiton pattern * + * -------------------------------------------------------------------------------------------------------------- + * THIS IS CONSIDERED TO BE AN ANTI-PATTERN! FOR BETTER TESTABILITY AND MAINTAINABILITY USE DEPENDENCY INJECTION! + * -------------------------------------------------------------------------------------------------------------- + * * Purpose: * to have only a list of named instances that are used, like a singleton but with n instances * diff --git a/Singleton/Singleton.php b/Singleton/Singleton.php index 75c2dd6..3a42582 100644 --- a/Singleton/Singleton.php +++ b/Singleton/Singleton.php @@ -5,6 +5,10 @@ namespace DesignPatterns\Singleton; /** * Singleton pattern * + * -------------------------------------------------------------------------------------------------------------- + * THIS IS CONSIDERED TO BE AN ANTI-PATTERN! FOR BETTER TESTABILITY AND MAINTAINABILITY USE DEPENDENCY INJECTION! + * -------------------------------------------------------------------------------------------------------------- + * * Purpose: * to have only one instance of this object in the application that will handle all calls * @@ -12,7 +16,6 @@ namespace DesignPatterns\Singleton; * - DB Connector * - Logger (may also be a Multiton if there are many log files for several purposes) * - Lock file for the application (there is only one in the filesystem ...) - * */ class Singleton {