<?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>Rich Buggy</title>
	<atom:link href="http://www.buggy.id.au/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.buggy.id.au</link>
	<description>Together we could upgrade the universe</description>
	<lastBuildDate>Sun, 20 Dec 2009 11:34:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>API equals dollars</title>
		<link>http://www.buggy.id.au/2009/12/20/api-equals-dollars/</link>
		<comments>http://www.buggy.id.au/2009/12/20/api-equals-dollars/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 11:34:29 +0000</pubDate>
		<dc:creator>Rich</dc:creator>
				<category><![CDATA[Start-ups]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.buggy.id.au/?p=349</guid>
		<description><![CDATA[Lately I&#8217;ve been looking at a number of SaaS providers covering a range of areas. It amazes me how many of them have no API or only a reporting API. If you&#8217;re thinking of building a SaaS start-up then you should be thinking about creating an API that allows your customers to do everything they can [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been looking at a number of SaaS providers covering a range of areas. It amazes me how many of them have no API or only a reporting API. If you&#8217;re thinking of building a SaaS start-up then you should be thinking about creating an API that allows your customers to do <strong><em>everything</em></strong> they can with your user interface.</p>
<p>Service providers with this API have an obvious advantage when it comes to migration and integration but they also have a more subtle and more important advantage. When reviewing potential providers I looked at those with an API before those without. Your SaaS may be the best but without this API are potential customers even considering you?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.buggy.id.au/2009/12/20/api-equals-dollars/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Please sack the NSW Government</title>
		<link>http://www.buggy.id.au/2009/12/03/please-sack-the-nsw-government/</link>
		<comments>http://www.buggy.id.au/2009/12/03/please-sack-the-nsw-government/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 10:17:33 +0000</pubDate>
		<dc:creator>Rich</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.buggy.id.au/?p=347</guid>
		<description><![CDATA[Committing unlawful acts one month, Premier elect the next.
The NSW Government has imploded and is no longer capable of governing this state. It&#8217;s time for the Governor of NSW to stand up for the people of NSW. If this is all we have left to run the state then it&#8217;s time to sack the government.
]]></description>
			<content:encoded><![CDATA[<p><a title="Minister's unlawful act scuppers 7200 homes" href="http://www.smh.com.au/national/ministers-unlawful-act-scuppers-7200-homes-20091018-h2y0.html">Committing unlawful acts one month</a>, <a title="Keneally first female NSW Premier" href="http://www.smh.com.au/national/keneally-first-female-nsw-premier-20091203-k8j0.html">Premier elect the next</a>.</p>
<p>The NSW Government has imploded and is no longer capable of governing this state. It&#8217;s time for the Governor of NSW to stand up for the people of NSW. If this is all we have left to run the state then it&#8217;s time to sack the government.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.buggy.id.au/2009/12/03/please-sack-the-nsw-government/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WebBlast</title>
		<link>http://www.buggy.id.au/2009/11/30/webblast/</link>
		<comments>http://www.buggy.id.au/2009/11/30/webblast/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 22:21:36 +0000</pubDate>
		<dc:creator>Rich</dc:creator>
				<category><![CDATA[Conferences]]></category>

		<guid isPermaLink="false">http://www.buggy.id.au/?p=345</guid>
		<description><![CDATA[It&#8217;s that time of year again. Tickets are available now http://www.webblast.com.au/
]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s that time of year again. Tickets are available now <a href="http://www.webblast.com.au/">http://www.webblast.com.au/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.buggy.id.au/2009/11/30/webblast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Where&#8217;s the data Nathan?</title>
		<link>http://www.buggy.id.au/2009/10/15/wheres-the-data-nathan/</link>
		<comments>http://www.buggy.id.au/2009/10/15/wheres-the-data-nathan/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 09:54:32 +0000</pubDate>
		<dc:creator>Rich</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.buggy.id.au/?p=341</guid>
		<description><![CDATA[After reading Pia&#8217;s post about opening up government data I went back to a post I made the day the NSW Government announced that it was opening up government data. That was the 4th September. We were promised that a trial feed was being tested and a full feed would be opened on 21st Septemer. [...]]]></description>
			<content:encoded><![CDATA[<p>After reading Pia&#8217;s post about <a href="http://pipka.org/blog/2009/10/15/opening-up-government-data-get-hacking-people/">opening up government data</a> I went back to a post I made the day the NSW Government announced that it was opening up government data. That was the 4<sup>th</sup> September. We were promised that a trial feed was being tested and a full feed would be opened on 21<sup>st</sup> Septemer. It&#8217;s now 15<sup>th</sup> October (nearly a month after the feed <strong>should</strong> have started) and the one government dataset covering NSW comes  from the Commonwealth Government.</p>
<p>Where&#8217;s the data Nathan?</p>
<p>Let&#8217;s be honest. The Commonwealth Government has started to open access to data. So have other states. The NSW Government has simply extended it&#8217;s policy of making grand announcements with no intention of following through. If there really is data available then put it in your <a href="http://data.nsw.gov.au/">data catalogue</a> so we can find it!?!? I guess they&#8217;ll re-announce this every 12 months in between announcing yet another rail line that won&#8217;t be built.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.buggy.id.au/2009/10/15/wheres-the-data-nathan/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NSW opens up data</title>
		<link>http://www.buggy.id.au/2009/09/04/nsw-opens-up-data/</link>
		<comments>http://www.buggy.id.au/2009/09/04/nsw-opens-up-data/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 09:38:45 +0000</pubDate>
		<dc:creator>Rich</dc:creator>
				<category><![CDATA[Start-ups]]></category>

		<guid isPermaLink="false">http://www.buggy.id.au/?p=333</guid>
		<description><![CDATA[Normally I&#8217;m highly critical of the NSW Government but they seem to finally be doing something right. According to Builder AU the NSW Government is now starting to open data to developers. They&#8217;re even running a competition for developers and have an entire website dedicate to providing public sector information. Sadly the site doesn&#8217;t contain [...]]]></description>
			<content:encoded><![CDATA[<p>Normally I&#8217;m highly critical of the NSW Government but they seem to finally be doing something right. According to Builder AU the NSW Government is now starting to <a title="Rees opens govt data to developers" href="http://www.builderau.com.au/news/soa/Rees-opens-govt-data-to-developers/0,339028227,339298306,00.htm">open data to developers</a>. They&#8217;re even running a <a title="apps4nsw" href="http://www.information.nsw.gov.au/apps4nsw">competition for developers</a> and have an entire website dedicate to providing <a title="Open Public Sector Information" href="http://www.data.nsw.gov.au/">public sector information</a>. Sadly the site doesn&#8217;t contain anything yet but at least they seem to heading in the right direction.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.buggy.id.au/2009/09/04/nsw-opens-up-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unit tests</title>
		<link>http://www.buggy.id.au/2009/08/28/unit-tests/</link>
		<comments>http://www.buggy.id.au/2009/08/28/unit-tests/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 13:09:06 +0000</pubDate>
		<dc:creator>Rich</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[sydphp]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://www.buggy.id.au/?p=330</guid>
		<description><![CDATA[I just read a post asking if my unit test take too long. In it the author suggests that 5 minutes is long and asks if anyone has solved this problem. This reminded me of a discussion I had with some developers about 12 months ago about unit testing in which my argument was simply [...]]]></description>
			<content:encoded><![CDATA[<p>I just read a post asking if <a href="http://www.advogato.org/person/robertc/diary/111.html">my unit test take too long</a>. In it the author suggests that 5 minutes is long and asks if anyone has solved this problem. This reminded me of a discussion I had with some developers about 12 months ago about unit testing in which my argument was simply that unit tests need to be comprehensive and not necessarily quick.</p>
<p>There are many projects where the unit tests take several hours to run. This shouldn&#8217;t matter during development when you&#8217;re probably only interested in a few unit tests as most test tools provide a way to filter the tests that are run. You only need to run the entire test suite prior to committing or during continuous integration.</p>
<p>Having said all of that I can recommend using memory tables if your database supports them. The operations are generally a lot faster as the database doesn&#8217;t need to write to disk.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.buggy.id.au/2009/08/28/unit-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Planet MicroISV</title>
		<link>http://www.buggy.id.au/2009/08/05/planet-microisv/</link>
		<comments>http://www.buggy.id.au/2009/08/05/planet-microisv/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 12:56:16 +0000</pubDate>
		<dc:creator>Rich</dc:creator>
				<category><![CDATA[Start-ups]]></category>
		<category><![CDATA[microisv]]></category>
		<category><![CDATA[planet-microisv.com]]></category>

		<guid isPermaLink="false">http://www.buggy.id.au/?p=313</guid>
		<description><![CDATA[I was a big fan of Planet MicroISV. The site aggregated blogs from a number of MicroISV&#8217;s around the world. Unforunately it seemed to disappear in late April this year. Today I found the time to launch a new Planet MicroISV with a new URL (http://planet-microisv.com/). Luckily Google Reader allowed me to recover a number [...]]]></description>
			<content:encoded><![CDATA[<p>I was a big fan of Planet MicroISV. The site aggregated blogs from a number of MicroISV&#8217;s around the world. Unforunately it seemed to disappear in late April this year. Today I found the time to launch a new <a title="Planet MicroISV" href="http://www.planet-microisv.com/">Planet MicroISV</a> with a new URL (<a title="Planet MicroISV" href="http://planet-microisv.com/">http://planet-microisv.com/</a>). Luckily Google Reader allowed me to recover a number of feeds the old site aggregated.</p>
<p>If you want your blog added (or removed) then send me an email <a href="mailto:rich@buggy.id.au">rich@buggy.id.au</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.buggy.id.au/2009/08/05/planet-microisv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Migrating to the Zend Framework</title>
		<link>http://www.buggy.id.au/2009/07/15/migrating-to-the-zend-framework/</link>
		<comments>http://www.buggy.id.au/2009/07/15/migrating-to-the-zend-framework/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 01:57:02 +0000</pubDate>
		<dc:creator>Rich</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[sydphp]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://www.buggy.id.au/?p=247</guid>
		<description><![CDATA[I don&#8217;t usually blog about work but I think this may interest some people. Late last year we trialled the Zend Framework in a small application. A few months ago we begun the process of converting our main PHP application to it. The migration is still in the early stages so some of this may change [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t usually blog about work but I think this may interest some people. Late last year we trialled the Zend Framework in a small application. A few months ago we begun the process of converting our main PHP application to it. The migration is still in the early stages so some of this may change rapidly.</p>
<p>We decided on the Zend Framework because it was component based. This was important because we have an existing code base with a regular release schedule. Stopping development while we converted the application wasn&#8217;t an option so we needed something that could be integrated slowly.</p>
<p>So how are we doing this?</p>
<p>The first task was to replace the applications module structure with auto loading. While this reduced the number of files that needed to be included to process a request the biggest advantage was making the code more visible to the developers. Prior to this classes were hidden 2, 3 or 4 levels deep in modules. The immediate impact was finding a number of classes that were no longer required.</p>
<p>Next I was expecting to replace some of the more discrete components like logging but it didn&#8217;t turn out this way. Because of the applications development schedule work instead focused on migrating from our custom MVC to the Zend Framework MVC.</p>
<p>After writing a bootstrap file  we created controllers and actions. The release cycle wasn&#8217;t long enough to completely convert the old MVC so the new actions simply call the old code. This approach allowed us convert the front controller (without session management and authentication) in about a day and means that new code can be written using the Zend Framework instead of our old framework.  Custom routing was required to emulate some of the old URLs.</p>
<p>The session management and authentication took about to day to sort out on its own. All of the controllers share a common base class. It&#8217;s init() function provides some common functionality:</p>
<ol>
<li>Initialize the view</li>
<li>Initialize the session (except the API or AJAX controllers)</li>
<li>Set all actions as requiring authentication</li>
</ol>
<p>Starting sessions is done in the controllers init() function instead of the bootstrap file so we can prevent sessions from being started for API calls. This is important because we get a large number of API calls and none of them requires a session. The other important task for init() is to mark some actions as not requiring authentication.</p>
<p>Authentication itself takes place in the controllers preDispatch() function. This provided backwards compatibility with the way the application previously worked.</p>
<p>More recently we&#8217;ve begun removing static methods from business logic so that we can use dependency injection to make testing easier. I&#8217;ll post about this next time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.buggy.id.au/2009/07/15/migrating-to-the-zend-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internet Villain of the Year</title>
		<link>http://www.buggy.id.au/2009/07/13/internet-villain-of-the-year/</link>
		<comments>http://www.buggy.id.au/2009/07/13/internet-villain-of-the-year/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 12:34:24 +0000</pubDate>
		<dc:creator>Rich</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.buggy.id.au/?p=307</guid>
		<description><![CDATA[Congratulations to Stephen Conroy and Australian Government on your most recent award. It&#8217;s just a guess but I don&#8217;t think they&#8217;ll be promoting this at the next election.
]]></description>
			<content:encoded><![CDATA[<p>Congratulations to Stephen Conroy and Australian Government on your <a title="Internet Villain of the Year" href="http://www.ispaawards.org.uk/page/home">most recent award</a>. It&#8217;s just a guess but I don&#8217;t think they&#8217;ll be promoting this at the next election.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.buggy.id.au/2009/07/13/internet-villain-of-the-year/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamic forms using Zend_Form</title>
		<link>http://www.buggy.id.au/2009/06/21/dynamic-forms-using-zend-form/</link>
		<comments>http://www.buggy.id.au/2009/06/21/dynamic-forms-using-zend-form/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 02:31:12 +0000</pubDate>
		<dc:creator>Rich</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[sydphp]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://www.buggy.id.au/?p=260</guid>
		<description><![CDATA[While most forms contain fixed fields there are occasions when you need a form to be dynamic and adjust itself based on user input. The adjustment could be as simple as altering the options in a drop down list or as complex as adding/removing fields. In this post I&#8217;m going to cover how to create [...]]]></description>
			<content:encoded><![CDATA[<p>While most forms contain fixed fields there are occasions when you need a form to be dynamic and adjust itself based on user input. The adjustment could be as simple as altering the options in a drop down list or as complex as adding/removing fields. In this post I&#8217;m going to cover how to create a dynamic form using Zend_Form and jQuery. I&#8217;ll use the example of a registration form that prompts the user for their country and state. The requirements are pretty simple:</p>
<ol>
<li>It should only prompt for a state if the country has states.</li>
<li>The state list should only show states for the selected country.</li>
<li>The form should degrade gracefully so it works without Javascript</li>
</ol>
<p>To start I&#8217;m going to create a World class. This class has two functions. The first returns a list of countries. The second returns a list of states for a specified country or a list of all countries that have states plus the states in those countries. You might like to retrieve this information from a database but for simplicity I&#8217;ll hard code the information into the class.</p>
<pre>class World
{
    static private $_countries = array(
                       "AU" =&gt; "Australia",
                       "NZ" =&gt; "New Zealand");

    static private $_states = array(
		        "AU" =&gt; array(
		            "ACT" =&gt; "Australian Capital Territory",
		            "NSW" =&gt; "New South Wales",
		            "NT" =&gt; "Northern Territory",
		            "QLD" =&gt; "Queensland",
		            "SA" =&gt; "South Australia",
		            "TAS" =&gt; "Tasmania",
		            "VIC" =&gt; "Victoria"));

    public function getCountries()
    {
        return self::$_countries;
    }

    public function getStates($country = null)
    {
        if ($country === null) {
            return self::$_states;
        }
        if (array_key_exists($country, self::$_states)) {
            return self::$_states[$country];
        }
        return null;
    }
}</pre>
<p>Next I&#8217;ll create a class for the form (RegForm) by extending Zend_Form. This gives our registration form all of the advantages you get from Zend_Form including input filtering and validation. The form elements will be added in the constructor so that creating a new form is all you need to do to use it.</p>
<p>As our form needs to adapt based on user input the constructor needs to accept the user input as one of its parameters. This allows us to adjust the form elements based on the user input. All code using these parameters needs to be extremely careful as the user input has not been filtered or validated yet.</p>
<pre>class RegForm extends Zend_Form
{
    public function __construct($world, $params)
    {
        parent::__construct();

        $countries = $world-&gt;getCountries();
        $countryKeys = array_keys($countries);
        $thisCountry = isset($params['country']) ? $params['country'] : $countryKeys[0];
        $states = $world-&gt;getStates($thisCountry);

        $country = new Zend_Form_Element_Select('country');
        $country-&gt;setLabel('Country')
                -&gt;setMultiOptions($countries)
                -&gt;setValue($thisCountry)
                -&gt;setRequired(true);
        $this-&gt;addElement($country);

        $state = new Zend_Form_Element_Select('state');
        $state-&gt;setLabel('State');
        if ($states !== null) {
            $state-&gt;setMultiOptions($states)
                  -&gt;setRequired(true);
        } else {
            $state-&gt;setRegisterInArrayValidator(false);</pre>
<pre>        }
        $this-&gt;addElement($state);

        $submit = new Zend_Form_Element_Submit('submit');
        $submit-&gt;setValue('Add User')
               -&gt;setRequired(false);
        $this-&gt;addElement($submit);
    }
}</pre>
<p>There are two important things that RegForm does:</p>
<ol>
<li>The state options are adjusted to match the selected country.</li>
<li>The state is not validated if the country does not contain states.</li>
</ol>
<p>This means that our form will work exactly the way you expect Zend_Form to work. Without Javascript if you select a country and submit the form then the state list will adjust and display an error that the previously selected state was invalid. After you select a valid country and state the form will validate. If the selected country does not have states then the form with validate regardless of the selected state (providing there are no other errors).</p>
<p>I then need to create the controller.</p>
<pre>class AccountController extends Zend_Controller_Action
{
    public function indexAction()
    {
        $params = $this-&gt;_getAllParams();
        $world = new World();
        $form = new RegForm($world, $params);</pre>
<pre>        if ($this-&gt;_request-&gt;isPost() &amp;&amp; $form-&gt;isValid($params)) {
            // The form was valid!!
        }
        $this-&gt;view = $form;
    }
}</pre>
<p>Finally we can add Javascript to alter the form in browser. If you&#8217;re using the forms render() function then the Javascript will look something like this.</p>
<pre>    var countries = &lt;?php echo json_encode($this-&gt;world-&gt;getCountries()); ?&gt;;

    var states = &lt;?php echo json_encode($this-&gt;world-&gt;getStates()); ?&gt;

    function updateStates() {
        var state = $("#state");
        var country = $("#country");
        var hasStates = false;
        jQuery.each(states, function (cc, slist) {
            if (cc == country.val()) {
                hasStates = true;
                state.html('');
                jQuery.each(slist, function (code, name) {
                    state.append('&lt;option value="' +  code + '"&gt;' + name + '&lt;/option&gt;');
                });
            }
        });
        if (hasStates) {
            $("#state-label").css("display", "block");
            $("#state-element").css("display", "block");
        } else {
            $("#state-label").css("display", "none");
            $("#state-element").css("display", "none");
        }
    }</pre>
<pre>    $().ready(function () {
        $("#country").change(function () {
            updateStates();
        });
        var state = $("#state");
        if (state.val() == null) {
            $("#state-label").css("display", "none");
            $("#state-element").css("display", "none");
        }
    });</pre>
<p>This code takes care of hiding the states if they are not required and adjusting the states based on the selected country without needing to submit the form. With minimal effort I&#8217;ve been able to create a dynamic form using Zend_Form to do most of the hard work. Users with Javascript enabled get an A grade experience while those without Javascript can still use the form.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.buggy.id.au/2009/06/21/dynamic-forms-using-zend-form/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
