With an update about some of the content in his upcoming PHP Architect's Guide to PHP Design Patterns book, Jason Sweat talks about his previous writings on the Singleton pattern and why he's happy he wrote it how he did.
I was reviewing the editing of the Singleton chapter last night. It was kind of interesting to look it over again, as I originally wrote, and had the tech review performed, on this chapter back in December of 2004! Looking it over again I am pretty proud of the decisions I made in writing it. One important decision was to not make the Singleton pattern the first design pattern explained in the book. The actual sequence of chapters up to this point is: Preface, Programming Practices, The ValueObject Pattern, The Factory Pattern, The Singleton Pattern.
In the book I try to give equal coverage to PHP4 and PHP5, but this particular chapter I spend much more time with PHP4 examples, as having private constructors in PHP5 make implementing the pattern relatively easy. I cover several possible implementations, and highlight the fact that the Zend 1 engine does not store references in static variables (as noted in the manual).
I know that I, for one, am greatly looking forward to this book if for nothing more than to take a fresh look at how to structure my web applications to make them that much more efficient...




