note 70365 added to language.oop5.patterns

From: Date: Fri, 13 Oct 2006 08:19:17 +0000
Subject: note 70365 added to language.oop5.patterns
Groups: php.notes 
Request: Send a blank email to php-notes+get-118483@lists.php.net to get a copy of this message
Actually, there is no such thing as Singleton in PHP ... You can start from the definition of singleton: what is singleton? If singleton is defined as "singleton" per single user request or per single thread .. then, it is not better than caching a value under global variable and passing the value around ... Singleton pattern is a "single" object per one application context. If you have an e-commerce web application, then that singleton is a "unique" instance within the whole web application. Some folks here have greate idea "caching" things in session. So, my question, is it really singleton? No.. True singleton cannot be dupplicated in anyway. If in Java for example, if you get a singleton object and able persist it into some persistance layer (be it http session or database) and reload the persisted object to come out with earlier object, thus at the end I have identical 2 object having same value but occupying different memory addresss, then that is not Singleton. Singleton must be coded as Singleton, and it must not be compromised. Since there is no concept of multi threading in PHP, hence, there is no concept of Singleton .. Folks who are trying to wrote Singleton in PHP are basically nuts ... :)))) sorry .. no offence ... but it is a painful truth ... ---- Server IP: 83.138.144.80 Probable Submitter: 141.228.250.135 (proxied: 1.1 sgdchlnc03 (NetCache NetApp/6.0.3D2), Version 2.2-Build_Linux_1063 $Date: 11/16/2005 13:40:0013$(IWSS), 1.1 sgdchlnc03 (NetCache NetApp/6.0.3D2), 1.1 sgdprtnc01 (NetCache NetApp/6.0.3D2)) ---- Manual Page -- http://www.php.net/manual/en/language.oop5.patterns.php Edit -- https://master.php.net/note/edit/70365 Del: integrated -- https://master.php.net/note/delete/70365/integrated Del: useless -- https://master.php.net/note/delete/70365/useless Del: bad code -- https://master.php.net/note/delete/70365/bad+code Del: spam -- https://master.php.net/note/delete/70365/spam Del: non-english -- https://master.php.net/note/delete/70365/non-english Del: in docs -- https://master.php.net/note/delete/70365/in+docs Del: other reasons-- https://master.php.net/note/delete/70365 Reject -- https://master.php.net/note/reject/70365 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#118483) next »