New Efforts:
Blue Parabola, LLC
PHP'ers:
Ben Ramsey
Brandon Savage
Cal Evans
Eli White
Elizabeth Naramore
Joe LeBlanc
Justin Thorp
Matthew Turland
Matthew Weier O'Phinney
Rasmus Lerdorf
Tony Bibbs
Zend Blogs
Zend DevZone
DC Social Media:
Aaron Brazell
Jessie X
New Media Jim
Jimmy Gardner
Shashi B
Technologists:
O'Reilly Radar
Scott Berkun
Steve McConnell
Business/mISV:
Bob Walsh
Eric Sink
Gavin Bowman
Guy Kawasaki
Joel Spolsky
Micah Baldwin
Paul Graham
Planet mISV
Past Projects:
CodeSnipers
HOBY
Judicial Watch
mobile FoxNews.com
NRTW
web2Project
Great Tools I use:
Drupal
getClicky
phpUnit
Subversion
Zend Framework
This is not the home of dotProject or web2project. It is the home of CaseySoftware, LLC. Any dotProject support questions should be referred to their support forums.
At php|tek 2009 this year, I picked up a copy of php|architect's Guide to PHP Design Patterns by Jason Sweat. In the following month (June), I read it and took a number of notes.
First off, personally, I come from a Java background and got deep into Design Patterns there. Reading Fowler's "Patterns of Enterprise Architecture" and "Refactoring", they just made sense. Stepping into the PHP world initially (2003-2004?), things were a mess. This was pre-PHP5, so Objects were mediocre at best. Spaghetti code was king. And well, you get the picture. In the last few years, there's been a gradual - yet growing - shift in the maturity of the tools, community, and practices. This book serves as an example of it.
Diving into the book itself, Jason covers 16 Design Patterns. He covers the basic ones like the dreaded and horribly abused and misused Singleton to the more advanced Active Record and Table Data Gateway. While he covers all of them to a good depth, there are a number that deserve special mention:
The Strategy Pattern - This pattern encapsulates the Object Oriented concept of polymorphism nicely, so it deserves special attention, especially if you're new to OO in general. Since lots of PHP developers don't have a classical computer science background - like myself - this is an important concept to figure out and master. Jason does a nice writeup using extensive code samples and even developing tests throughout to demonstrate how it should work.
The Mock Object Pattern - Here Jason cheats just a little bit as the Mock Object is not technically a Design Pattern in the traditional sense. Anyway,the point of a Mock Object is to mimic a limited resource for testing purposes. This can be something simple - like a filesystem - or something horribly complex like a third-party service. Either way, the Mock Object mimics the resource close enough for testing purposes and is a useful one to know.
The Observer Pattern - This is one of the places the book really shines. I've looked for a good implementation of the Observer in PHP land for a number of years and just hadn't found one until now. Jason walks us through the example covering the basics of attaching and notifying all the interested Observers and setting up a variety of loggers behind the scenes.
One of the major strengths of the book is the Unit Testing. Jason steps through every example building out the tests to go along with the code. While most people claim that they do testing, this is a very in-your-face and "see it works!" way of approaching things. Which makes sense considering the approach. Build a litte, write the tests. Build some more, write the tests. Refactoring it, refactor some tests. It's am amazing way to make sure things behave exactly the same way (externally) as they did before.
As an aside, solid Unit Testing has saved me hours of headaches as we've fleshed out the tests for the Companies and Projects Modules within web2project.
The biggest weakness of the book is simply the age. It was published in July 2005 just as PHP5 was coming to life. As a result, most of the code samples are PHP4-specific. Of course, if there was ever a time for a second edition, this would be it. Beyond the maturity and change in the PHP community, we've also seen the Rise of the Frameworks. The vast majority of us are using MVC, Table Data Gateway, Unit Testing, and a variety of other Desisn Patterns that this book shines at covering. Looking at these concepts from a non-framework view would be incredibly valuable.
*hint*hint*
Overall, I give this one an 8... with the potential of going higher with some updated code samples using the OO-goodness of PHP5.
*hint*hint*
Disclosure: Although I traveled with the author - Jason Sweat - for the first half of CodeWorks on behalf of MTA, I read this book well before the trip. Am I biased? Yeah, probably. But that doesn't make me wrong...
Agreed++
I picked this one up in 2007 and went through it. Working in a (still prevalent) PHP4 shop, that half of the code examples probably felt more at home for me ;-)
I too would be quick to pick up a PHP5.3-based revision, and would be tickled to see its TDD aspects utilizing PHPUnit.
Updated PHP Patterns Book
Hey! I just thought I'd drop a note and let you know that I've written a book through Wiley Publishing that picks up where this one left off. It doesn't cover PHP 5.3 examples (as it wasn't out at the time of writing), but it does feature PHP5 code only. It covers some similar design patterns as well as some different ones from this original book. Finally, it winds up with a really in depth study of designing and implementing an application using these design patterns.
Please check it out: aaronsaray.com/book - I would love to hear your review. Thanks!
-aaron
Needs re-writing agreed
Hi,
Agree with you on needing a re-write, and it is important because it does fill an important gap.
I wish that some of the examples were more aligned to everyday PHP problems, but overall it was an important part of my learning curve - Mock Objects was a bit win for me.
I am pro-SimpleTest, but still winced it did not use PHPUnit for half the examples.
Smaller text, more patterns would have been better.
I still recommend this book to people on Forums when they are struggling with OOP.
Go on, Jason.
Didn't like it much
I tried reading through this one but didn't like it much. May be cos of the PHP flavour. Do you know of any other good ones for php?
Thx
Tim.E
Post new comment