As PHP 5 nears completion, more powerful object-orientation becomes available to developers. Heavyweight programming processes are highly regarded but rarely used; PHP is treated with derision but is ubiquitous. How does the PHP developer in the trenches resolve this?
By doing what the PHP's architects did, of course: cherry picking the most pragmatic of OOP principles and patterns! This introduction is targeted at the PHP developer who has basic knowledge of PHP OOP syntax but wants to find out where OOP principles can fit into a program.
With examples illustrating the use of simple design patterns both good and bad, it covers some basic principles of object orientation (such as the open-closed principle and the single-responsibility principle), parameters of package design, and other related processes (such as refactoring and test-first design). If that last sentence made no sense, then this talk is for you!
bookmarks
about
- Vancouver PHP Association Conference 2004: This talk was given at this conference in Vancouver, Canada on 23 January 2004, 2:30-4:00 pm
- abstract: The abstract of this talk.
introduction
Two eXtreme People
- FuzzyBlog: Feedster: This is Scott's old blog where I found the quote about not thinking you could do design patterns in PHP. I'm sorry I didn't bookmark the permalink. (Scott now has a new blog).
- Migrating from PHP to ASP.NET (powerpoint): This is good for a laugh if you're not easily offended.
- Migrating from PHP to ASP.NET: Microsoft FUD on why APSP.NET is better than PHP. It's filled iwth myths about PHP not being object-oriented enough based on the faulty premise that rigorous OO is inherently better
- Pattern Snobs on JDJ: This is where I had a web-reference to the quote I read in Java Developer's Journal. Unfortunately, I think the link is now dead.
The Middle Way
- Shu-Ha-Ri: Where else to find a relevant explanation of Shu-Ha-Ri other than the Patterns Wiki?
Some basic PHP O-O
- The object-oriented evolution in PHP: Zeev Suraski writes about OO in older versions of PHP with a look to the future. This is the source of the "2AM bug" quote.
- PHP4 OO: The author of JPGraph ran into the same PHP4 OO quirks that I did.
- PHP Static Class Variable: The most reliably (though ugly) method of getting static class variables to work in PHP 4. Note that PHP 5 has static class variables built in.
1. methodology
metaphors
- What is Software Engineering?: Jack Reeve's 1992 paper in C++ Journal that touched off a paradigm shift back to the obvious: that programmers are engineers and programming is engineering.
- The Source Code is the Design: This Agile Process maxim is spawned from Jack Reeve's paper.
agility
Overview
- Why Scripting Languages Matter: science and engineering. How is engineering science? and how is sketching any different than what engineers do all the time before writing design documents. The argument doesn't refute the hypothosis.
Test First Design
- Test First Design: A complete essay on Test First Design
- jUnit: One of the nicests unit testing framework. This is written for Java and has been ported by many people to PHP.
- phpUnit Cookbook: This is where I got the code example I showed. I demoed my own codebase
- SourceForge PHPUnit: I recommend this version of PHPUnit for PHP3 and PHP4. If there are bugs with this, e-mail me and I'll fix them.
- PEAR PHPUnit homepage: This is the version of PHPUnit to use for PHP5. Has MockObject support, suport for multiple renders (GTK GUI client, command line, HTML), and deesign-by-contract documentation support. Excellent!
Refactoring
- Refactoring: Homepage for Martin Fowler's 1999 book on Refactoring.
You Aren't Going to Need It (YAGNI)
- You Aren't Going To Need It: This is the pattern repository's definition of YAGNI and the one I used for my talk.
- Java is the SUV of programming tools: This is where teh quote about J2EE efficiency comes from. Philip Greenspun teaches software engineering MIT.
- Iterator Pattern: ::phpPatterns website shows a PHP implementation of the iterator pattern.
- PHP Eclipse ProjectPage: An PHP O-O class library that has the misfortune of having the Iterator pattern in it.
Agile processes not covered
- Extreme Programming: A gentle introduction: Go here first when trying to learn about XP
- Extreme Programming Refactored: This is a book that tries to poke fun of extreme programming by claiming the emporer has no clothes. From reading the review you see how the authors are stuck in the "ha" stage. They critique the rote "shu" without an inkling to the "ri" behind them.
- Five Lessons You Should Learn from Extreme Programming: This gives a simple summary of the main ideas behind Extreme Programming.
- Manifesto for Agile Software Development: ey could agree on. Bah! The last time I got to ski at Snowbird was when I was 11.
2. principles
precepts of classes
- TestDox: This documents a design-by-contract by reading the names of Unit Test methods. This is incorporated into PEAR PHPUnit.
parameters of package design
- Eureka!: Sterling Hughes's Eureka! moment gives some choice quotes about PHP vs. ASP.NET
- The Leaning Tower of Pisa: Scientific American article from 1995 about attempts to prevent the leaning tower of Pisa from falling further
what are patterns?
- UI Patterns and Techniques: The traditional "what is a design pattern" is usually based on the historical book of patterns in architecture. I believe user-interface patterns are more intuitively answer "what is a design pattern" to most PHP programmers.
- Weilie web patterns in interaction design: Perhaps even more relevant are UI patterns which are specific to web design
- Portland Pattern Repository: The pattern wiki
- jUnit: A Cook's Tour: A very complete description of all the patterns used in making jUnit (and consequently both versions of PHPUnit) and why.
3. patterns
Observer pattern
- phpDocumentor: A great tool for autodocumenting your source code based on inline (JavaDoc) commenting. This is being completely rewritten for PHP5.
XML Messaging
- REpresentational State Transfer: An alternative to XML-based services.
More reading...
- Object Orientation Tips: Further reading on Object-Orientation
conclusion
