<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>thinsoldier.com &#187; webdev</title>
	<atom:link href="http://thinsoldier.com/wordpress/archives/tag/webdev/feed" rel="self" type="application/rss+xml" />
	<link>http://thinsoldier.com/wordpress</link>
	<description>what the !@#%! were you expecting?</description>
	<lastBuildDate>Mon, 09 Aug 2010 14:54:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title></title>
		<link>http://thinsoldier.com/wordpress/archives/51</link>
		<comments>http://thinsoldier.com/wordpress/archives/51#comments</comments>
		<pubDate>Fri, 05 Feb 2010 21:11:44 +0000</pubDate>
		<dc:creator>thinsoldier</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[designpatterns]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://thinsoldier.com/wordpress/?p=51</guid>
		<description><![CDATA[This is a comment I had about <a href="http://www.phpdesignpatterns.com/design-patterns/pattern-decorator/">an article on the Decorator pattern </a>

I think some people may overlook the importance/usefulness of the decorator pattern since all you're doing in the examples could be accomplished by just concatenating P and /P around the getData() wherever it is you were going to display it. <a href="http://thinsoldier.com/wordpress/archives/51">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is a comment I had about <a href="http://www.phpdesignpatterns.com/design-patterns/pattern-decorator/">an article on the Decorator pattern </a></p>
<p>I think some people may overlook the importance/usefulness of the decorator pattern since all you&#8217;re doing in the examples could be accomplished by just concatenating P and /P around the getData() wherever it is you were going to display it.</p>
<p>I find the decorator pattern is best for when you have a lot of parts to the data that need a lot of manipulation of their values and a lot of html but not so much html that it warrants a full page/template/view.</p>
<p>For example <span id="more-51"></span> in my (poorly written) real estate site I have an object that represents a property for sale in the listings table of the DB. All 126 fields of the property record!</p>
<p>When it&#8217;s time to show info about the property to a visitor I only need to show them about a dozen fields. But most of those fields need to be manipulated. I need to ucfirst() the property status text, convert the price to Euros/Pounds/USD/BSD, attach the http://www.site.com/listings/&#8230; onto the permalink text of the listing, convert 3.5 into &#8220;3 1/2 Bath&#8221;, convert the square feet values into Acres if they are over 1 acres in size and lots of other stuff. Also all these fields had to be wrapped in html tags and ids and css classes etc.</p>
<p>At first I had all that stuff as part of the code that happens _before_ the data is saved to the database. Then other clients came along who wanted the same system (but different) and I realized a lot of those manipulations were only relevant to the site visitors. So then I put those instructions in the main class file as $listing-&gt;displayOverview() method.</p>
<p>But then some more clients came along who wanted something other than the default set of info in the default format. Some clients wanted the category value to link to a search results page of everything in that category. Some wanted the neighbourhood value to do the same. Some didn&#8217;t want the category or neighbourhood value to be shown. Sure I could have just use css to hide the neighbourhood span but some high end clients don&#8217;t want anyone to know where their house is located so the neighbourhood/address values weren&#8217;t allowed to be anywhere in the markup. They had to be taken out at the code level.</p>
<p>It unfortunately took a looong time and a lot of clients on this system to realize I needed to take this segment of my code and turn it into a custom decorator for each client that needed one.</p>
<p>Before that realization, at one point I had a site identifier variable and a ton of IF statements strewn throughout the code that made it a nightmare to read!</p>
<p>For another good example of decorator usage see this <a href="http://www.zend.com/en/webinar/Framework/webinar-leveraging-zend_form-decorators-20091216.flv">Zend Framework Zend_Form screencast</a> (requires having a zend.com account).</p>
]]></content:encoded>
			<wfw:commentRss>http://thinsoldier.com/wordpress/archives/51/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
