 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
IBM developerWorks: Five more PHP design patterns
by Chris Cornutt March 28, 2008 @ 08:49:35
The IBM developerWorks site has a new article posted that talks about design patterns, five of them in particular, that can help to "accelerate your PHP development" and make your code more maintainable down the line.
As an application developer, you can have a lifelong career without ever knowing what any of the patterns are called or how or when they're used. However, I've found that a good working knowledge of these patterns, as well as those introduced in the developerWorks article "Five common PHP design patterns" (see Resources), allows you to do two things: Enable high-bandwidth conversations and reduce painful lessons.
The patterns they talk about in this "five more" article of the series are:
- Adapter Pattern
- Iterator Pattern
- Decorator Pattern
- Delegate Pattern
- State Pattern
Diagrams are provided for each of them, showing how they flow along with brief code examples (structures really) to show how that transitions over to actual use.
voice your opinion now!
design patterns tutorial adapter iterator decorator delegate state
Zend Developer Zone: Decorating with External Data
by Chris Cornutt September 27, 2006 @ 08:50:00
On the Zend Developer Zone today, there's this new tutorial that looks at making the move from PHP4's object-oriented programming up to the "more complete obejct model of PHP5" - specifically with the Decorator design pattern.
While working on a project I realized one particular solution was a pretty good way to demonstrate the decorator design pattern together with some of PHP5's features, including abstract classes, interfaces, type hinting, the final keyword and the visibility of properties and methods. This article is intended for those of you who, like myself, are moving from object-oriented programming, including some use of design patterns, in PHP4, to the more complete object model of PHP5.
He sets up a scenario about the development of an online pizza ordering system to show how to "decorate" a pizza with each of the toppings on a list (instead of having to list out every pizza in every possible topping combination). Of course, all of the code is included and explained so you understand exactly what's happening. Finally, there's a demonstration of its usage - a simple call that grabs the stock level/name/cost of each of the items in stock (pizza combinations).
voice your opinion now!
decorator pattern pizza object oriented combination decorator pattern pizza object oriented combination
DevShed: Working with MySQL Result Sets and the Decorator Pattern in PHP
by Chris Cornutt September 06, 2006 @ 06:58:38
DevShed continues its look at the Decorator pattern with this new article today talking about working with MySQL result sets inside of the structure of the Decorator pattern.
Definitely, the pattern in question can be used for generating different types of outputs (or views) based on a returned result set, by using a few decorator classes that I'll define in the course of this tutorial. Hopefully, when you finish reading these lines, you should have a clear idea of how to include decorator classes in your object-based PHP applications.
They start off by showing how they're going to handle the MySQL result sets normally with a class and how to use that class in an example. Finally, they tie all of that in with the Decorator pattern, creating multiple Decorator classes to handle the various MySQL result set types.
voice your opinion now!
decorator pattern mysql result set tutorial part2 decorator pattern mysql result set tutorial part2
DevShed: An Introduction to Using the Decorator Pattern with PHP
by Chris Cornutt August 28, 2006 @ 11:23:53
In yet another of their looks at using patterns in PHP, DevShed has posted the first part of a new three-part series today covering the Decorator patten, useful for adding new or other functionality to prexisting objects.
Due to the wide range of web applications where the decorator pattern can be successfully applied, over the course of this series, I'll show you some useful pointers to demonstrate how this pattern works, and how it can be introduced in your own PHP applications with only minor hassles. Before you start reading the rest of this article, make sure that you have a pretty good understanding of object-based programming with PHP, since you'll see an abundance of material related to this topic.
To help you get started, they start at ground level with a basic class, one to save a string to a file. They then, in a different class, build the Decorator object, adding the ability to reset and display the string. To help out, they also make two other classes to make the string either all uppercase or all lowercase. Finally, they tie them all together, amking an application that adds its functionality on the fly.
voice your opinion now!
pattern decorator dynamic functionality tutorial stringsaver pattern decorator dynamic functionality tutorial stringsaver
|
Community Events
Don't see your event here? Let us know!
|