<?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>Hacked For BBQ</title>
	<atom:link href="http://hackedforbbq.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://hackedforbbq.com</link>
	<description>Hacking the Codez for BBQ</description>
	<lastBuildDate>Thu, 09 Apr 2009 16:05:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=3.0-alpha</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Fresh Meat</title>
		<link>http://hackedforbbq.com/2009/04/fresh-meat/</link>
		<comments>http://hackedforbbq.com/2009/04/fresh-meat/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 22:21:28 +0000</pubDate>
		<dc:creator>corycollier</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[looks]]></category>
		<category><![CDATA[new]]></category>
		<category><![CDATA[site]]></category>

		<guid isPermaLink="false">http://hackedforbbq.com/?p=61</guid>
		<description><![CDATA[We&#8217;ve updated our site. The look is much more reflective of the values we have at Hacked: Code, Death Metal, and Horror. We&#8217;ve done a few things to keep the new design both appealing and usable. The combined focus of pretty (kinda) and readable will make all of you cower in fear.
We&#8217;ve implemented the famous [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve updated our site. The look is much more reflective of the values we have at Hacked: Code, Death Metal, and Horror. We&#8217;ve done a few things to keep the new design both appealing and usable. The combined focus of pretty (kinda) and readable will make all of you cower in fear.</p>
<p>We&#8217;ve implemented the famous sIFR technique to display headings in non-standard web fonts. Windows, Mac, and Linux do very few things the same way. The one thing they all do the same though, is render Serif, Sans-Serif, and monospaced fonts the same. While we&#8217;ve gone with a monospaced font for the content of this site (a homage to coders everywhere), it was our feeling that the headings should be much different. Keeping with the grungy theme of the vertical logo, we used the same font for the h2 and h3 headings.</p>
<p>We&#8217;ve also kept the base font-size at the default level. There&#8217;s a great article about this <a href="http://informationarchitects.jp/100e2r/">here</a>, with a lot of reasoning for not altering the base font size. The takeaway for us: most screens aren&#8217;t that small anymore and small text is just too hard to read.</p>
<p>So, we&#8217;re all new. We hope you like it. You&#8217;d better &#8230;</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://hackedforbbq.com/2009/04/fresh-meat/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dual Boot OS X 10.5 and Ubuntu 8.10</title>
		<link>http://hackedforbbq.com/2009/03/dual-boot-os-x-105-and-ubuntu-810/</link>
		<comments>http://hackedforbbq.com/2009/03/dual-boot-os-x-105-and-ubuntu-810/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 03:30:55 +0000</pubDate>
		<dc:creator>corycollier</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://hackedforbbq.com/?p=39</guid>
		<description><![CDATA[First of all, this isn&#8217;t easy. Dual booting Ubuntu and OS X requires a very specific set of instructions. There is no quick way around this, so get a cup of coffee, and settle down. You will be working on this for the next couple of hours.
With the disclaimer out of the way, I can [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>First of all, this isn&#8217;t easy. Dual booting Ubuntu and OS X requires a very specific set of instructions. There is no quick way around this, so get a cup of coffee, and settle down. You will be working on this for the next couple of hours.</p>
<p>With the disclaimer out of the way, I can say that I&#8217;m running Ubuntu 8.10 (Intrepid) on my 24&#8243; iMac, alongside the typical OS X 10.5 (Leopard) software that comes with the machine. The results are stunning. I have never seen Linux look so amazing, as it does on the machine I&#8217;m writing this tutorial on. If you&#8217;ve got some patience, I highly recommend performing this.</p>
<p>So, I&#8217;ll presume that you&#8217;re already running OS X (Leopard) on the existing Apple computer. The first thing you&#8217;ll need to do, is to use the Bootcamp Assistant Utility to set aside some hard-drive space for Linux. This is a trivial task, but make sure you leave enough space for Ubuntu to run comfortably, as well as double your RAM amount (which will be used as swap space by Ubuntu).</p>
<p><img class="alignnone size-full wp-image-40" title="Bootcamp" src="http://hackedforbbq.com/wp-content/uploads/2009/03/bootcamp-300x230.png" alt="Bootcamp" width="300" height="230" /></p>
<p>In case that&#8217;s confusing, the amount to give Ubuntu = Ubuntu Disk Space + ( 2 * RAM)</p>
<p>Once you&#8217;ve done that, you&#8217;ll be prompted to start the assisted install of windows. DO NOT ALLOW THIS. Kindly click the &#8216;Finish Later&#8217; button, and close the program.</p>
<p>The next thing  you&#8217;ll need to do, is <a title="Install rEFIt, to allow for dual booting of a Mac." href="http://refit.sourceforge.net/doc/c1s1_install.html">install rEFIt</a>. rEFIt modifies the boot setup for the Mac, to allow for multiple boot scenarios. This is a very necessary step, before trying to install Ubuntu on the freshly reserved hard-drive space. The install of rEFIt is easy. Mount the image that comes with the download, and run the package. No configuration required <img src='http://hackedforbbq.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Once you&#8217;ve gotten that done, you&#8217;ll need to insert the Ubuntu install disk into the CD / DVD drive of your computer, and restart. rEFIt is supposed to recognize the disk on boot, and provide you the option to choose what you want to boot from. This wasn&#8217;t the case for me however. So, just to be safe, when you restart your computer, hold down the &#8216;c&#8217; key as soon as the machine starts back up. This should force the computer to boot from CD, thus allowing you to run the Ubuntu install.</p>
<p>Go through the typical steps to install Ubuntu, until you get to the disk options. Once there, you should be able to click the option to &#8216;install to the largest continuous free space&#8217;. Again, I was not able to do this. I got a bunch of errors when I tried to do this, so I had to setup the Ubuntu partitions manually.</p>
<p>If you don&#8217;t need to setup the Ubuntu partitions manually (i.e., the i&#8217;nstall to the largest continuous free space&#8217; option works for you), skip past the next instructions.</p>
<p>If you do need to setup the Ubuntu partitions manually,  here&#8217;s how to do it:</p>
<ol>
<li>Select the manual option instead of the &#8216;install to the largest continuous free space&#8217; option.</li>
<li>Select the Free Space partition of the hard drive.</li>
<li>Create one partion, equal to twice the amount of RAM in your computer, and set it&#8217;s type to Swap.</li>
<li>Select the newly modified Free Space partition of the hard drive.</li>
<li>Create one partition, equal to the remaining free space,</li>
<li>Select the option to format the drive</li>
<li>Set the filesystem to ext3.</li>
</ol>
<p>Click &#8216;Forward&#8217; to proceed to the last part of the install. Once here, you&#8217;ll need to &#8216;Advanced&#8217; button to specify where GRUB will be loaded. If you were able to use the  &#8216;install to the largest continuous free space&#8217; option, then select /dev/sda3, if you had to do a manual partition setup, then select /dev/sda4.</p>
<p><img class="alignnone size-full wp-image-41" title="Click Advanced" src="http://hackedforbbq.com/wp-content/uploads/2009/03/step7.png" alt="Click Advanced" width="450" height="317" /></p>
<p>Finally, let the install proceed. Ubuntu usually takes about an hour to install, so go mow the yard or something. Once the install is done, the CD will be ejected. You&#8217;ll see a prompt to remove the disk, and press enter to complete the install. Do this.</p>
<p>When the computer reboots, you should see the rEFIt screen. This screen will have a few options, but one of them (a small option in the lower left of the icons) will be the partition tool. Run that option. A quick script will run, and you&#8217;ll be prompted to continue. Confirm this option. Afterwards, shutdown the computer. Do not restart the computer. You need to specifically shut it down.</p>
<p><img class="alignnone size-full wp-image-42" title="rEFIt" src="http://hackedforbbq.com/wp-content/uploads/2009/03/screen2-300x225.png" alt="rEFIt" width="300" height="225" /></p>
<p>Finally, turn the computer back on. You&#8217;ve done it. Hoo-ray.</p>
<p>I&#8217;d like to take the time to thank the MactelSupportTeam for the instructions they provided at their own site :</p>
<p><a href="https://help.ubuntu.com/community/MactelSupportTeam/AppleIntelInstallation">https://help.ubuntu.com/community/MactelSupportTeam/AppleIntelInstallation</a></p>
<p>They&#8217;ve provided a number of boot scenario tutorials that are amazing, and well worth the read.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://hackedforbbq.com/2009/03/dual-boot-os-x-105-and-ubuntu-810/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Repair Broken iPhone Screen</title>
		<link>http://hackedforbbq.com/2009/03/repair-broken-iphone-screen/</link>
		<comments>http://hackedforbbq.com/2009/03/repair-broken-iphone-screen/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 01:00:49 +0000</pubDate>
		<dc:creator>corycollier</dc:creator>
				<category><![CDATA[Devices]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[repair]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://hackedforbbq.com/?p=36</guid>
		<description><![CDATA[Recently, I had the opportunity (problem) to replace my wife&#8217;s iPhone screen. I broke it, by dropping it on our tile floor. the digitizer was completely intact, but the glass covering it was shattered. We were lucky that we were using a clear film protector over the glass, which helped keep everything in place.
At first, [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Recently, I had the opportunity (problem) to replace my wife&#8217;s iPhone screen. I broke it, by dropping it on our tile floor. the digitizer was completely intact, but the glass covering it was shattered. We were lucky that we were using a clear film protector over the glass, which helped keep everything in place.</p>
<p>At first, I figured I&#8217;d use the AppleCare plan we purchased to have the phone replaced / repaired. Apparently, Apple&#8217;s AppleCare plan&#8217;s do not cover accidental damage. They told us that the phone could be replaced at the subsidized cost ($199.99). As you can imagine, I was a bit upset with Apple.</p>
<p>Since I&#8217;m a technical guy, I figured I&#8217;d find a way to repair the screen myself. I found a site (pdaparts.com) that sells replacement screens for $49.99. That&#8217;s way cheaper than what I was expecting, so why not? I&#8217;ve <a title="Replace MacBook Screen" href="http://tweakosx.com/index.php/2007/11/19/replace-macbook-screen-a-tutorial/">replaced MacBook screens</a> before, so how hard could the iPhone be?</p>
<p>The hardest thing ever.<span id="more-36"></span></p>
<p>PDA Parts has an excellent video detailing the steps to disassemble the iPhone, down to the glass-digitizer combination. After that, there are no instructions at all. The site&#8217;s narrative basically stops there and says &#8216;Good luck! Let us know if it works out for you.&#8217;. Once I realized this, I was already in too deep. So, I went ahead and finished the job.</p>
<p>The iPhone screen can be replaced, but it is definitely the most difficult repair I have ever done. If I had the chance to go back, I would easily take the $199.99 repair from Apple over doing this myself. It was immeasurably difficult, and I do not recommend it. for those of you with a strong stomach, here&#8217;s how it goes:</p>
<p>First, the video from PDA Parts :</p>
<p><object width="425" height="344" data="http://www.youtube.com/v/8fF0DF-mbn4&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/8fF0DF-mbn4&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /></object></p>
<p>From there, you&#8217;re pretty much neck deep in a disassembled iPhone. You&#8217;ll need to separate the existing glass from the chassis that houses both it, and the digitizer underneath. This is the especially tricky part. I was better able to do this, by utilizing the location where the existing glass on the phone was broken. Using an exacto-knife, I was able to separate the glass from the chassis.</p>
<p>I can&#8217;t emphasize enough how much care should be taken when doing this. First of all, every component of your iPhone is extremely delicate. Secondly, you are dealing with broken glass. I cut my hand a lot getting the glass off. That sort of thing doesn&#8217;t bother me, but if you&#8217;re not a fan of bleeding hands, be very careful.</p>
<p>Once the old glass has been completely separated from the chassis, use the exacto-knife to ensure all of the existing adhesive has been removed from the chassis. When you apply the new adhesive strips (yes, you must buy those too), you&#8217;ll need a completely clean surface to attach the new glass to.</p>
<p>After you&#8217;ve gotten this done, very carefully apply the adhesive strips to their respective places in the chassis. You&#8217;ll only get one chance at this, so make it count. There&#8217;s a pink covering on the front of the adhesive strips. Leave this in place for now. Once you have both the adhesive strips in place, then you can remove the pink coverings.</p>
<p>Now, you can put the new screen on the chassis. Make sure to remove any plastic coverings before doing this. Like I said: you only get one chance at this.</p>
<p>After the screen is on, you&#8217;ll pretty much need to perform the takedown, in reverse to put the iPhone back together again. This part isn&#8217;t exceptionally difficult, with one major exception</p>
<p>The cable marked &#8216;3&#8242; that connects the digitizer to the main board is very tough to get back on. I managed to make this happen, but I&#8217;m certainly open to hear any suggestions on how to make this work.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://hackedforbbq.com/2009/03/repair-broken-iphone-screen/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Decorator Pattern</title>
		<link>http://hackedforbbq.com/2009/03/decorator-pattern/</link>
		<comments>http://hackedforbbq.com/2009/03/decorator-pattern/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 05:56:56 +0000</pubDate>
		<dc:creator>corycollier</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[design pattern]]></category>
		<category><![CDATA[ood]]></category>
		<category><![CDATA[oop]]></category>

		<guid isPermaLink="false">http://hackedforbbq.com/?p=31</guid>
		<description><![CDATA[In our ongoing series about design patterns, we introduce the Decorator Pattern. The decorator pattern serves to add specific functionality to an existing class. The classic example of this is in GUI programming, when a widget needs a border, or graphic surrounding it. Not using the Decorator Pattern, one might just subclass out the widget [...]


Related posts:<ol><li><a href='http://hackedforbbq.com/2009/03/observer-pattern/' rel='bookmark' title='Permanent Link: Observer Pattern'>Observer Pattern</a> <small>One of my favorite design patterns, is the Observer Pattern. The Observer...</small></li><li><a href='http://hackedforbbq.com/2009/03/factory-pattern/' rel='bookmark' title='Permanent Link: Factory Pattern'>Factory Pattern</a> <small>In following the theme of design patterns we&#8217;re starting this...</small></li><li><a href='http://hackedforbbq.com/2009/03/singleton-pattern/' rel='bookmark' title='Permanent Link: Singleton Pattern'>Singleton Pattern</a> <small>One of the things I see all the time with...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>In our ongoing series about design patterns, we introduce the Decorator Pattern. The decorator pattern serves to add specific functionality to an existing class. The classic example of this is in GUI programming, when a widget needs a border, or graphic surrounding it. Not using the Decorator Pattern, one might just subclass out the widget class and add a border to the subclassed widget. This becomes more difficult however, when there are multiple classes of widgets. This becomes almost impossible when dealing with a collection of widgets.</p>
<p>So, enter the Decorator Pattern.<span id="more-31"></span></p>
<p>The easiest way to realize the decorator pattern, is simply to pass the decorated class to the decorator&#8217;s constructor function, then expose whatever functions of the decorated class you desire, adding functionality as necessary. So, here&#8217;s an example of a widget class (the decorated), that get&#8217;s decorated by the decorator:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #00ff00; font-weight: bold;">class</span> Widget
<span style="color: #ff00ff;">&#123;</span>
    <span style="color: #666666; font-style: italic;">/**
     * property to hold the data for the widget
     * @var array $_data
     */</span>
    <span style="color: #00ff00; font-weight: bold;">private</span> <span style="color: #00ffff;">$_data</span> <span style="color: #ffff00;">=</span> <span style="color: #00ff00;">array</span><span style="color: #ff00ff;">&#40;</span><span style="color: #ff00ff;">&#41;</span><span style="color: #ffff00;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">/**
     * function to draw a widget from the existing data
     */</span>
    <span style="color: #00ff00; font-weight: bold;">public</span> <span style="color: #00ff00; font-weight: bold;">function</span> draw <span style="color: #ff00ff;">&#40;</span> <span style="color: #ff00ff;">&#41;</span>
    <span style="color: #ff00ff;">&#123;</span>   <span style="color: #666666; font-style: italic;">// CREATE a local variable to represent the result</span>
        <span style="color: #00ffff;">$markup</span> <span style="color: #ffff00;">=</span> <span style="color: #00ffff;">''</span><span style="color: #ffff00;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// ITERATE through each of the key/value pairs in the _data property ...</span>
        <span style="color: #ffff00;">foreach</span> <span style="color: #ff00ff;">&#40;</span><span style="color: #00ffff;">$this</span><span style="color: #ffff00;">-&amp;</span>gt<span style="color: #ffff00;">;</span>_data <span style="color: #ffff00;">as</span> <span style="color: #00ffff;">$key</span> <span style="color: #ffff00;">=&amp;</span>gt<span style="color: #ffff00;">;</span> <span style="color: #00ffff;">$value</span><span style="color: #ff00ff;">&#41;</span>
        <span style="color: #ff00ff;">&#123;</span>   <span style="color: #666666; font-style: italic;">// APPEND the key/value pair to the markup variable</span>
            <span style="color: #00ffff;">$markup</span> <span style="color: #ffff00;">.=</span> <span style="color: #ff0000;">&quot;
&lt;dt&gt;{$key}&lt;/dt&gt;
&lt;dd&gt;{$value}&lt;/dd&gt;
&nbsp;
&quot;</span><span style="color: #ffff00;">;</span>
        <span style="color: #ff00ff;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// RETURN the result, wrapped in a dl tag</span>
        <span style="color: #ffff00;">return</span> <span style="color: #ff0000;">&quot;
&lt;dl&gt;{$markup}&lt;/dl&gt;
&nbsp;
&quot;</span><span style="color: #ffff00;">;</span>
&nbsp;
    <span style="color: #ff00ff;">&#125;</span> <span style="color: #666666; font-style: italic;">// END draw</span>
&nbsp;
<span style="color: #ff00ff;">&#125;</span> <span style="color: #666666; font-style: italic;">// END Widget</span>
&nbsp;
<span style="color: #00ff00; font-weight: bold;">class</span> WidgetDecorator
<span style="color: #ff00ff;">&#123;</span>
    <span style="color: #666666; font-style: italic;">/**
     * property to hold the item that will be decorated
     */</span>
    <span style="color: #00ff00; font-weight: bold;">private</span> <span style="color: #00ffff;">$_decoratedObject</span><span style="color: #ffff00;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">/**
     * Constructor
     * @param object $DecoratedObject
     */</span>
    <span style="color: #00ff00; font-weight: bold;">public</span> <span style="color: #00ff00; font-weight: bold;">function</span> __construct <span style="color: #ff00ff;">&#40;</span><span style="color: #00ffff;">$DecoratedObject</span><span style="color: #ff00ff;">&#41;</span>
    <span style="color: #ff00ff;">&#123;</span>   <span style="color: #666666; font-style: italic;">// SET the _decoratedObject property to the object that was provided</span>
        <span style="color: #00ffff;">$this</span><span style="color: #ffff00;">-&amp;</span>gt<span style="color: #ffff00;">;</span>_decoratedObject <span style="color: #ffff00;">=</span> <span style="color: #00ffff;">$DecoratedObject</span><span style="color: #ffff00;">;</span>
    <span style="color: #ff00ff;">&#125;</span> <span style="color: #666666; font-style: italic;">// END __construct</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">/**
     * function to expose the draw method of the _decoratedObject
     */</span>
    <span style="color: #00ff00; font-weight: bold;">public</span> <span style="color: #00ff00; font-weight: bold;">function</span> draw <span style="color: #ff00ff;">&#40;</span> <span style="color: #ff00ff;">&#41;</span>
    <span style="color: #ff00ff;">&#123;</span>   <span style="color: #666666; font-style: italic;">// RETURN the result of the _decoratedObject's draw method, wrapped in a div</span>
        <span style="color: #ffff00;">return</span> <span style="color: #00ffff;">'
&lt;div class=&quot;decorated&quot;&gt;'</span> <span style="color: #ffff00;">.</span> <span style="color: #00ffff;">$this</span><span style="color: #ffff00;">-&amp;</span>gt<span style="color: #ffff00;">;</span>_decoratedObject<span style="color: #ffff00;">-&amp;</span>gt<span style="color: #ffff00;">;</span>draw<span style="color: #ff00ff;">&#40;</span><span style="color: #ff00ff;">&#41;</span> <span style="color: #ffff00;">.</span> <span style="color: #00ffff;">'&lt;/div&gt;
'</span><span style="color: #ffff00;">;</span>
    <span style="color: #ff00ff;">&#125;</span> <span style="color: #666666; font-style: italic;">// END draw</span>
&nbsp;
<span style="color: #ff00ff;">&#125;</span> <span style="color: #666666; font-style: italic;">// END WidgetDecorator</span></pre></div></div>

<p>While it&#8217;s common to talk about GUI implementations of the Decorator Pattern, there are several other implementations that fit the Decorator Pattern idea. You might need to wrap an event logger, that already logs events to one log, with a user notifying system that also notifies users. You might need to do all kinds of things.</p>
<p>The idea here, is that any time  you need specific functionality added to a class (or set thereof), you might consider the Decorator Pattern.</p>


<p>Related posts:<ol><li><a href='http://hackedforbbq.com/2009/03/observer-pattern/' rel='bookmark' title='Permanent Link: Observer Pattern'>Observer Pattern</a> <small>One of my favorite design patterns, is the Observer Pattern. The Observer...</small></li><li><a href='http://hackedforbbq.com/2009/03/factory-pattern/' rel='bookmark' title='Permanent Link: Factory Pattern'>Factory Pattern</a> <small>In following the theme of design patterns we&#8217;re starting this...</small></li><li><a href='http://hackedforbbq.com/2009/03/singleton-pattern/' rel='bookmark' title='Permanent Link: Singleton Pattern'>Singleton Pattern</a> <small>One of the things I see all the time with...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://hackedforbbq.com/2009/03/decorator-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Observer Pattern</title>
		<link>http://hackedforbbq.com/2009/03/observer-pattern/</link>
		<comments>http://hackedforbbq.com/2009/03/observer-pattern/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 02:32:37 +0000</pubDate>
		<dc:creator>corycollier</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[design pattern]]></category>
		<category><![CDATA[ood]]></category>
		<category><![CDATA[oop]]></category>

		<guid isPermaLink="false">http://hackedforbbq.com/?p=27</guid>
		<description><![CDATA[One of my favorite design patterns, is the Observer Pattern. The Observer Pattern is used far more often then you might realize. The Observer Pattern is quintessential, for instance, in most GUI applications. Most applications that respond to key strokes, mouse clicks, or network updates use Observer Pattern. The idea, is that some object in the application is observable, and it [...]


Related posts:<ol><li><a href='http://hackedforbbq.com/2009/03/decorator-pattern/' rel='bookmark' title='Permanent Link: Decorator Pattern'>Decorator Pattern</a> <small>In our ongoing series about design patterns, we introduce the...</small></li><li><a href='http://hackedforbbq.com/2009/03/factory-pattern/' rel='bookmark' title='Permanent Link: Factory Pattern'>Factory Pattern</a> <small>In following the theme of design patterns we&#8217;re starting this...</small></li><li><a href='http://hackedforbbq.com/2009/03/singleton-pattern/' rel='bookmark' title='Permanent Link: Singleton Pattern'>Singleton Pattern</a> <small>One of the things I see all the time with...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>One of my favorite design patterns, is the Observer Pattern. The Observer Pattern is used far more often then you might realize. The Observer Pattern is quintessential, for instance, in most GUI applications. Most applications that respond to key strokes, mouse clicks, or network updates use Observer Pattern. The idea, is that some object in the application is observable, and it has other objects that observe it.</p>
<p>It&#8217;s a lot like a bunch of soldiers waiting for the order to charge. The general is observable, and the soldiers are observers. When the general gives an order, the soldiers react in a way appropriate to the order. This is the essence of the Observer Pattern. Here&#8217;s the class diagram of the situation :<span id="more-27"></span></p>
<p><img class="alignnone size-full wp-image-28" title="Observer Pattern" src="http://hackedforbbq.com/wp-content/uploads/2009/03/observer.jpg" alt="Observer Pattern" width="560" height="88" /></p>
<p>The difference between the Observer Pattern and other design patterns mentioned here, is that there are (at least) two classes required to implement the Observer Pattern. One class is the Observable. It binds to events in the Observable class. The second class is the Observable class. This class is the traffic cop for the entire system. This class will define where the Observer will receive notifications regarding the state of the Observable object. Here&#8217;s some basic code to make the point:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #ffff00;">&amp;</span>lt<span style="color: #ffff00;">;</span> ?php
<span style="color: #666666; font-style: italic;">/**
 * Class that is the general to the soldiers
 */</span>
<span style="color: #00ff00; font-weight: bold;">class</span> Observable
<span style="color: #ff00ff;">&#123;</span>
    <span style="color: #00ff00; font-weight: bold;">private</span> <span style="color: #00ffff;">$_observers</span> <span style="color: #ffff00;">=</span> <span style="color: #00ff00;">array</span><span style="color: #ff00ff;">&#40;</span><span style="color: #ff00ff;">&#41;</span><span style="color: #ffff00;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">/**
     * public function to add observers to the stack
     */</span>
    <span style="color: #00ff00; font-weight: bold;">public</span> <span style="color: #00ff00; font-weight: bold;">function</span> addObserver <span style="color: #ff00ff;">&#40;</span>Observer <span style="color: #00ffff;">$observer</span><span style="color: #ff00ff;">&#41;</span>
    <span style="color: #ff00ff;">&#123;</span>   <span style="color: #666666; font-style: italic;">// APPEND the provided observer to the observer stack</span>
        <span style="color: #00ffff;">$this</span><span style="color: #ffff00;">-&amp;</span>gt<span style="color: #ffff00;">;</span>_observers<span style="color: #ff00ff;">&#91;</span><span style="color: #ff00ff;">&#93;</span> <span style="color: #ffff00;">=</span> <span style="color: #00ffff;">$observer</span><span style="color: #ffff00;">;</span>
    <span style="color: #ff00ff;">&#125;</span> <span style="color: #666666; font-style: italic;">// END addObserver</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">/**
     * function to let the observers know to check the status of the observable object
     */</span>
    <span style="color: #00ff00; font-weight: bold;">public</span> <span style="color: #00ff00; font-weight: bold;">function</span> notifyObservers <span style="color: #ff00ff;">&#40;</span> <span style="color: #ff00ff;">&#41;</span>
    <span style="color: #ff00ff;">&#123;</span>   <span style="color: #666666; font-style: italic;">// ITERATE through each of the observers in the stack ...</span>
        <span style="color: #ffff00;">foreach</span> <span style="color: #ff00ff;">&#40;</span><span style="color: #00ffff;">$this</span><span style="color: #ffff00;">-&amp;</span>gt<span style="color: #ffff00;">;</span>_observers <span style="color: #ffff00;">as</span> <span style="color: #00ffff;">$observer</span><span style="color: #ff00ff;">&#41;</span>
        <span style="color: #ff00ff;">&#123;</span>   <span style="color: #666666; font-style: italic;">// UPDATE the observer</span>
            <span style="color: #00ffff;">$observer</span><span style="color: #ffff00;">-&amp;</span>gt<span style="color: #ffff00;">;</span>Update<span style="color: #ff00ff;">&#40;</span><span style="color: #00ffff;">$this</span><span style="color: #ff00ff;">&#41;</span><span style="color: #ffff00;">;</span>
        <span style="color: #ff00ff;">&#125;</span>
    <span style="color: #ff00ff;">&#125;</span> <span style="color: #666666; font-style: italic;">// END notifyObservers</span>
&nbsp;
<span style="color: #ff00ff;">&#125;</span> <span style="color: #666666; font-style: italic;">// END Observable</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/**
 * Class that is the soldiers to the genereal
 */</span>
<span style="color: #00ff00; font-weight: bold;">class</span> Observer
<span style="color: #ff00ff;">&#123;</span>
    <span style="color: #666666; font-style: italic;">/**
     * Implementation of the observer's update function
     */</span>
    <span style="color: #00ff00; font-weight: bold;">public</span> <span style="color: #00ff00; font-weight: bold;">function</span> Update <span style="color: #ff00ff;">&#40;</span>Observable <span style="color: #00ffff;">$observable</span><span style="color: #ff00ff;">&#41;</span>
    <span style="color: #ff00ff;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// do whatever it is that the observer should do when notified</span>
    <span style="color: #ff00ff;">&#125;</span> <span style="color: #666666; font-style: italic;">// END Notify</span>
&nbsp;
<span style="color: #ff00ff;">&#125;</span> <span style="color: #666666; font-style: italic;">// END Observer</span></pre></div></div>



<p>Related posts:<ol><li><a href='http://hackedforbbq.com/2009/03/decorator-pattern/' rel='bookmark' title='Permanent Link: Decorator Pattern'>Decorator Pattern</a> <small>In our ongoing series about design patterns, we introduce the...</small></li><li><a href='http://hackedforbbq.com/2009/03/factory-pattern/' rel='bookmark' title='Permanent Link: Factory Pattern'>Factory Pattern</a> <small>In following the theme of design patterns we&#8217;re starting this...</small></li><li><a href='http://hackedforbbq.com/2009/03/singleton-pattern/' rel='bookmark' title='Permanent Link: Singleton Pattern'>Singleton Pattern</a> <small>One of the things I see all the time with...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://hackedforbbq.com/2009/03/observer-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Factory Pattern</title>
		<link>http://hackedforbbq.com/2009/03/factory-pattern/</link>
		<comments>http://hackedforbbq.com/2009/03/factory-pattern/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 22:42:08 +0000</pubDate>
		<dc:creator>corycollier</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[factory]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[ood]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[oriented]]></category>
		<category><![CDATA[pattern]]></category>

		<guid isPermaLink="false">http://hackedforbbq.com/?p=22</guid>
		<description><![CDATA[In following the theme of design patterns we&#8217;re starting this site off with, we&#8217;re talking about the Factory Pattern here. The Factory Pattern, true to it&#8217;s name, acts as a factory to produce objects depending on the parameters provided to it.
A common example of this are configuration objects. Suppose you&#8217;ve setup a configuration for you&#8217;re [...]


Related posts:<ol><li><a href='http://hackedforbbq.com/2009/03/singleton-pattern/' rel='bookmark' title='Permanent Link: Singleton Pattern'>Singleton Pattern</a> <small>One of the things I see all the time with...</small></li><li><a href='http://hackedforbbq.com/2009/03/observer-pattern/' rel='bookmark' title='Permanent Link: Observer Pattern'>Observer Pattern</a> <small>One of my favorite design patterns, is the Observer Pattern. The Observer...</small></li><li><a href='http://hackedforbbq.com/2009/03/decorator-pattern/' rel='bookmark' title='Permanent Link: Decorator Pattern'>Decorator Pattern</a> <small>In our ongoing series about design patterns, we introduce the...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>In following the theme of design patterns we&#8217;re starting this site off with, we&#8217;re talking about the Factory Pattern here. The Factory Pattern, true to it&#8217;s name, acts as a factory to produce objects depending on the parameters provided to it.</p>
<p>A common example of this are configuration objects. Suppose you&#8217;ve setup a configuration for you&#8217;re application to use an XML configuration file to run. Now, let&#8217;s say for some unknown reason, you need to use an INI file for configuration. Or, let&#8217;s say that today you&#8217;re using MySQL for database storage, but tomorrow, you might be forced to use Oracle.</p>
<p>Having to find where you create the instances of classes could be difficult, or maybe even impossible. The solution to this dilemma, is to use factory pattern to produce objects where any future ambiguity might cause a disaster.</p>
<p>Typically, the way a factory is implemented is to implement some sort of class that acts as a quasi-gateway to the object that&#8217;s needed. To keep things simple, we&#8217;ll assume we&#8217;re trying to get a database object and we need to not worry about the actual implementation of the database<span id="more-22"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #ffff00;">&amp;</span>lt<span style="color: #ffff00;">;</span> ?php
<span style="color: #00ff00; font-weight: bold;">class</span> Database
<span style="color: #ff00ff;">&#123;</span>
    <span style="color: #666666; font-style: italic;">/**
     * function to return the type of database object required by the user
     *
     * @return DatabaseObject
     */</span>
    <span style="color: #00ff00; font-weight: bold;">public</span> <span style="color: #00ff00;">static</span> <span style="color: #00ff00; font-weight: bold;">function</span> factory <span style="color: #ff00ff;">&#40;</span> <span style="color: #00ffff;">$type</span> <span style="color: #ffff00;">=</span> <span style="color: #00ffff;">'mysql'</span> <span style="color: #ff00ff;">&#41;</span>
    <span style="color: #ff00ff;">&#123;</span>   <span style="color: #666666; font-style: italic;">// SWITCH based on the type of database required</span>
        <span style="color: #ffff00;">switch</span> <span style="color: #ff00ff;">&#40;</span><span style="color: #00ff00;">strtolower</span><span style="color: #ff00ff;">&#40;</span><span style="color: #00ffff;">$type</span><span style="color: #ff00ff;">&#41;</span><span style="color: #ff00ff;">&#41;</span>
        <span style="color: #ff00ff;">&#123;</span>   <span style="color: #666666; font-style: italic;">// CASE the adapter requested is MS-SQL</span>
            <span style="color: #ffff00;">case</span> <span style="color: #00ffff;">'mssql'</span><span style="color: #ffff00;">:</span>
                <span style="color: #ffff00;">return</span> MssqlDatabase<span style="color: #ffff00;">::</span><span style="color: #ffffff;">getInstance</span><span style="color: #ff00ff;">&#40;</span><span style="color: #ff00ff;">&#41;</span><span style="color: #ffff00;">;</span>
                <span style="color: #ffff00;">break</span><span style="color: #ffff00;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">// CASE the adapter requested is SQL Lite</span>
            <span style="color: #ffff00;">case</span> <span style="color: #00ffff;">'sqlite'</span><span style="color: #ffff00;">:</span>
                <span style="color: #ffff00;">return</span> <span style="color: #00ff00; font-weight: bold;">new</span> Sqlite<span style="color: #ffff00;">;</span>
                <span style="color: #ffff00;">break</span><span style="color: #ffff00;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">// CASE the adapter requested is Oracle</span>
            <span style="color: #ffff00;">case</span> <span style="color: #00ffff;">'oracle'</span><span style="color: #ffff00;">:</span>
                <span style="color: #ffff00;">return</span> OracleDatabase<span style="color: #ffff00;">::</span><span style="color: #ffffff;">getInstance</span><span style="color: #ff00ff;">&#40;</span><span style="color: #ff00ff;">&#41;</span><span style="color: #ffff00;">;</span>
                <span style="color: #ffff00;">break</span><span style="color: #ffff00;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">// CASE the adapter requested is MySQL</span>
            <span style="color: #ffff00;">case</span> <span style="color: #00ffff;">'mysql'</span><span style="color: #ffff00;">:</span>
            <span style="color: #00ff00; font-weight: bold;">default</span><span style="color: #ffff00;">:</span>
                <span style="color: #ffff00;">return</span> MysqlDatabase<span style="color: #ffff00;">::</span><span style="color: #ffffff;">getInstance</span><span style="color: #ff00ff;">&#40;</span><span style="color: #ff00ff;">&#41;</span><span style="color: #ffff00;">;</span>
        <span style="color: #ff00ff;">&#125;</span>
    <span style="color: #ff00ff;">&#125;</span> <span style="color: #666666; font-style: italic;">// END factory</span>
&nbsp;
<span style="color: #ff00ff;">&#125;</span> <span style="color: #666666; font-style: italic;">// END Database</span></pre></div></div>

<p>Now, I threw the SQL Lite case in there to throw off the notion of just being able to dynamically call an adapter based on name required. Sometimes a simple <code>call_user_func</code> isn&#8217;t a possibility. On larger applications, it&#8217;s likely that there isn&#8217;t a rhyme or reason behind class names and methods being used to retrieve them.</p>


<p>Related posts:<ol><li><a href='http://hackedforbbq.com/2009/03/singleton-pattern/' rel='bookmark' title='Permanent Link: Singleton Pattern'>Singleton Pattern</a> <small>One of the things I see all the time with...</small></li><li><a href='http://hackedforbbq.com/2009/03/observer-pattern/' rel='bookmark' title='Permanent Link: Observer Pattern'>Observer Pattern</a> <small>One of my favorite design patterns, is the Observer Pattern. The Observer...</small></li><li><a href='http://hackedforbbq.com/2009/03/decorator-pattern/' rel='bookmark' title='Permanent Link: Decorator Pattern'>Decorator Pattern</a> <small>In our ongoing series about design patterns, we introduce the...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://hackedforbbq.com/2009/03/factory-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Singleton Pattern</title>
		<link>http://hackedforbbq.com/2009/03/singleton-pattern/</link>
		<comments>http://hackedforbbq.com/2009/03/singleton-pattern/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 17:49:28 +0000</pubDate>
		<dc:creator>corycollier</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[ood]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[oriented]]></category>
		<category><![CDATA[pattern]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[singleton]]></category>

		<guid isPermaLink="false">http://hackedforbbq.com/?p=12</guid>
		<description><![CDATA[One of the things I see all the time with developers, especially PHP ones, is a complete lack of understanding for basic computer science principles. Key among those principles missing from many programmers, are design patterns. While it could be said that some folks use design patterns far too much, most software guys / gals [...]


Related posts:<ol><li><a href='http://hackedforbbq.com/2009/03/factory-pattern/' rel='bookmark' title='Permanent Link: Factory Pattern'>Factory Pattern</a> <small>In following the theme of design patterns we&#8217;re starting this...</small></li><li><a href='http://hackedforbbq.com/2009/03/observer-pattern/' rel='bookmark' title='Permanent Link: Observer Pattern'>Observer Pattern</a> <small>One of my favorite design patterns, is the Observer Pattern. The Observer...</small></li><li><a href='http://hackedforbbq.com/2009/03/decorator-pattern/' rel='bookmark' title='Permanent Link: Decorator Pattern'>Decorator Pattern</a> <small>In our ongoing series about design patterns, we introduce the...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>One of the things I see all the time with developers, especially PHP ones, is a complete lack of understanding for basic computer science principles. Key among those principles missing from many programmers, are design patterns. While it could be said that some folks use design patterns far too much, most software guys / gals (especially freelancers) don&#8217;t use them nearly enough.</p>
<p>The idea behind design patterns, is to make routine the typical problems encountered by most software development. It&#8217;s likely that any problem get stuck in when trying to write the next biggest app in the world, someone already figured out. So, in much the same way that Object Oriented programming lets applications reuse code, Design Patterns help developers reuse algorithms and ideas.</p>
<p>The most basic, and classic design pattern is the Singleton Pattern. The principle, as you might have figured out, is to ensure singularity of an entity. There are some objects that should never be duplicated throughout the life of an application. Great examples of these are database connectors, request dispatchers, registries, etc &#8230;</p>
<p>So, at it&#8217;s most basic, a singleton is a class. What make it special, is that it&#8217;s constructor is not publicly available. Instead, the instance of the class is publicly available through a special method, getInstance. This function handles the acutally getting of the instance, and prevents duplication of the class.</p>
<p>Easy enough, here&#8217;s an example in PHP :<span id="more-12"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #ffff00;">&amp;</span>lt<span style="color: #ffff00;">;</span> ?php
<span style="color: #00ff00; font-weight: bold;">class</span> Foo
<span style="color: #ff00ff;">&#123;</span>
    <span style="color: #666666; font-style: italic;">/**
     * Property to contain the instance of the class
     *
     * @var Foo $_instance
     */</span>
    <span style="color: #00ff00; font-weight: bold;">private</span> <span style="color: #00ff00;">static</span> <span style="color: #00ffff;">$_instance</span><span style="color: #ffff00;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">/**
     * Privatize the constructor of the class, to prevent the public from getting crazy with it
     */</span>
    <span style="color: #00ff00; font-weight: bold;">private</span> <span style="color: #00ff00; font-weight: bold;">function</span> __construct <span style="color: #ff00ff;">&#40;</span> <span style="color: #ff00ff;">&#41;</span>
    <span style="color: #ff00ff;">&#123;</span>
    <span style="color: #ff00ff;">&#125;</span> <span style="color: #666666; font-style: italic;">// END private constructor</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">/**
     * The function that makes it all happen
     *
     * @return Foo
     */</span>
    <span style="color: #00ff00; font-weight: bold;">public</span> <span style="color: #00ff00;">static</span> <span style="color: #00ff00; font-weight: bold;">function</span> getInstance <span style="color: #ff00ff;">&#40;</span> <span style="color: #ff00ff;">&#41;</span>
    <span style="color: #ff00ff;">&#123;</span>   <span style="color: #666666; font-style: italic;">// IF the _instance property is not already set ...</span>
        <span style="color: #ffff00;">if</span> <span style="color: #ff00ff;">&#40;</span><span style="color: #ffff00;">!</span> <span style="color: #00ff00;">isset</span><span style="color: #ff00ff;">&#40;</span><span style="color: #00ff00; font-weight: bold;">self</span><span style="color: #ffff00;">::</span><span style="color: #00ffff;">$_instance</span><span style="color: #ff00ff;">&#41;</span><span style="color: #ff00ff;">&#41;</span>
        <span style="color: #ff00ff;">&#123;</span>
            <span style="color: #00ff00; font-weight: bold;">self</span><span style="color: #ffff00;">::</span><span style="color: #00ffff;">$_instance</span> <span style="color: #ffff00;">=</span> <span style="color: #00ff00; font-weight: bold;">new</span> <span style="color: #00ff00; font-weight: bold;">self</span><span style="color: #ffff00;">;</span>
        <span style="color: #ff00ff;">&#125;</span>
        <span style="color: #666666; font-style: italic;">// RETURN the instance of self</span>
        <span style="color: #ffff00;">return</span> <span style="color: #00ff00; font-weight: bold;">self</span><span style="color: #ffff00;">::</span><span style="color: #00ffff;">$_instance</span><span style="color: #ffff00;">;</span>
&nbsp;
    <span style="color: #ff00ff;">&#125;</span> <span style="color: #666666; font-style: italic;">// END getInstance</span>
&nbsp;
<span style="color: #ff00ff;">&#125;</span> <span style="color: #666666; font-style: italic;">// END Foo</span></pre></div></div>



<p>Related posts:<ol><li><a href='http://hackedforbbq.com/2009/03/factory-pattern/' rel='bookmark' title='Permanent Link: Factory Pattern'>Factory Pattern</a> <small>In following the theme of design patterns we&#8217;re starting this...</small></li><li><a href='http://hackedforbbq.com/2009/03/observer-pattern/' rel='bookmark' title='Permanent Link: Observer Pattern'>Observer Pattern</a> <small>One of my favorite design patterns, is the Observer Pattern. The Observer...</small></li><li><a href='http://hackedforbbq.com/2009/03/decorator-pattern/' rel='bookmark' title='Permanent Link: Decorator Pattern'>Decorator Pattern</a> <small>In our ongoing series about design patterns, we introduce the...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://hackedforbbq.com/2009/03/singleton-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
