3 ms·
I've been of the opinion for a while that static variables of any kind should be avoided except for const data (tables, constants, etc.). They make code very di
by api 14y ago
I've been of the opinion for a while that static variables of any kind should be avoided except for const data (tables, constants, etc.). They make code very difficult to impossible to port to multi-threaded environments, and make it hard to cleanly instantiate and then clean up a module within a larger program. Even things that feel like they should be global should be contained with a global context container that can be cleaned up.
- eamann 14y agoI agree. But remember, the article is specifically about singletons in WordPress, which is written in PHP, which is single-threaded.
- masklinn 14y ago> the article is specifically about singletons in WordPress Is that why you open with > I would argue that Singletons are not just useful, but are necessary for robust software development. ? No mention of wordpress there, you use it as an example but your assertion is that singletons are downright necessary to software development.
- mikeschinkel 14y ago@eamann, I gotta give @masklinn credit there, you didn't explicitly make it clear your post was focused on WordPress-related use-cases. It was obvious to me from your references and knowing your focus but maybe not obvious to those who don't specialize in WordPress if all they did was scan the article, as most people do.
- masklinn 14y agoNo, even reading the post it's not obvious. It's obvious that he talks about wordpress, but considering the assertion I quoted I simply read it as using a wordpress-based example/use case to support his hypothesis. At no point did I find or notice a modifier of the article being an argument for the usage of singletons in wordpress plugins. though I may just have missed it.