Page 2 of 2
Posted: Sat Sep 09, 2006 12:53 pm
by timvw
Why would a singleton be less evil in a c# or java environment anyway?
A singleton is only 'unique' in the current virtual machine that is executing the code...
Posted: Sat Sep 09, 2006 12:56 pm
by alex.barylski
adiian wrote:I think singleton is evil. From the oop perspective.
Can not be derived and if you want just to replace the class you have to chanage all the references in the text.
http://www.oodesign.com/oo_design_patte ... leton.html
And php is not a language with a good support for oop and design patterns. I would go for the configuration file in php. Otherwise, if using something like java or c#, I would chose singleton.
a. Not entirely sure I agree with that statement. A Singleton by itself cannot be derived from, however you could also implement getInstance as a factory method, allowing classes to derive from the singleton...
b. What crummy argument.

Sorry, but you provide no explanations to back why you feel PHP isn't a good OOP supported language...yes it has it's short falls, but OOP (IMHO) is more about paradigm & design choices than the compiler/interpreter specifics of each language (private, protected, public, const methods, etc)
You can utilize the concepts of OOP in assembler which historically has very few OOP constructs (depending on the assembler) and not much you can't work around anyways...
I disagree
Cheers

Posted: Sat Sep 09, 2006 7:05 pm
by Christopher
adiian wrote:I think singleton is evil. From the oop perspective. Can not be derived and if you want just to replace the class you have to chanage all the references in the text.
http://www.oodesign.com/oo_design_patte ... leton.html
And php is not a language with a good support for oop and design patterns. I would go for the configuration file in php. Otherwise, if using something like java or c#, I would chose singleton.
If you think using the Singleton pattern is "evil" then why would you use it in Java or C# ? I agree with your opinion, but I wouldn't use it anywhere.
As for whether PHP has "good support for oop and design patterns", perhaps you could start a new thread with this thesis. If done in an informative way, rather than a flame-fest, I think it would be interesting to PHP programmers to know how the PHP implement compares to how things are done in Java or C#.
Posted: Sun Sep 10, 2006 9:32 am
by Chris Corbyn
This thread is almost 6 months old
