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...
configuration: constants vs singleton pattern
Moderator: General Moderators
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
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...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.
b. What crummy argument.
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
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
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.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.
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#.
(#10850)
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia