Over the past couple of years, I’ve written a number of articles about using design patterns in WordPress. One that I’ve written about a number of times has to do with the Singleton Pattern.
Although I’m not really expecting anyone to spend time reading through the following list, some of the articles and/or comments that discuss the pattern include:
- An Introduction to the Singleton Pattern
- Properly Instantiate a WordPress Plugin
- Instantiating WordPress Plugins
- Object-Oriented WordPress Plugin Development
The funny thing about blogging is that when you’ve written something two years, one year, or even six months ago, you may not feel the same way as you did when you initially wrote the post. And that’s fine – as far as I’m concerned, it’s an indication of professional growth (or just getting better at what you do).
So with that said, I don’t use the singleton pattern as much as I used to the reasons for which are a topic for another discussion. Instead, I was recently talking with a good friend about implementing the singleton pattern within the context of a WordPress plugin and the discussion really came down to this:
Should plugins that implement the singleton pattern be instantiated in a hook?
Make sense? Continue reading
