<?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>Matt McCormick &#187; programming</title>
	<atom:link href="http://mattmccormick.ca/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://mattmccormick.ca</link>
	<description>Creating Solutions</description>
	<lastBuildDate>Wed, 11 Aug 2010 21:37:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Never Compromise Quality</title>
		<link>http://mattmccormick.ca/2010/04/27/never-compromise-quality/</link>
		<comments>http://mattmccormick.ca/2010/04/27/never-compromise-quality/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 16:03:36 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[character]]></category>
		<category><![CDATA[quality]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://mattmccormick.ca/?p=63</guid>
		<description><![CDATA[In programming people sometimes feel they have to sacrifice quality in order to get a product out the door on time.  Never do this.  You are hurting the customer, the company and yourself if you do.
This American Life had a very interesting program on the New United Motor Manufacturing Inc (NUMMI) plant in [...]]]></description>
			<content:encoded><![CDATA[<p>In programming people sometimes feel they have to sacrifice quality in order to get a product out the door on time.  Never do this.  You are hurting the customer, the company and yourself if you do.</p>
<p>This American Life had a very interesting program on the New United Motor Manufacturing Inc (NUMMI) plant in Freemont, California.  NUMMI was a joint venture started in 1984 between Toyota and GM for both parties to learn from each other.  GM would learn about Toyota&#8217;s quality control systems and Toyota would learn about building cars in America.</p>
<p>The amazing story is the turnaround of the plant.  Prior to the joint venture, the plant was operated by GM and was one of their worst factories.  The program talks about workers gambling, having sex, and drinking  at work.  They produced very low quality cars and didn&#8217;t really care.  The plant was closed as a result.  However, for this joint venture, GM agreed to re-open the plant and hired back many of the original workers.  Thanks to Toyota&#8217;s quality systems, the plant turned around to become one of the best GM had.</p>
<p>One example of change was &#8220;stopping the line.&#8221;  The GM workers grew up with the notion that you don&#8217;t stop the line.  If you notice something is wrong, you just keep it going.  Just get the cars out the door.  With Toyota&#8217;s system, workers were encouraged to stop the line if they noticed something wrong and fix it on the spot.  This was a big shift for them.  The process became about quality over quantity.  Within just three months, cars coming off the lot were being made with near perfect quality.</p>
<p>When you let an error slip, either with cars or with software, you are compounding the problem.  It takes much more time and money to fix the problem later than when it is first discovered.</p>
<p>How much more money?  One study estimated &#8220;it would take 50% more workers under the old system to produce the same car.&#8221;</p>
<p>Recently I had a situation like this.  I was responsible for checking over and delivering database scripts to a client.  I noticed one of the scripts had an input parameter and while I got a feeling I should double-check about it, I ignored that intuition and delivered them anyways.  The client ended up running the scripts in their environment but ignored the input parameter which caused part of the scripts to fail.  There was a lot of back and forth to get it fixed.  I estimate it probably wasted about one man-days worth of everybody&#8217;s time.  Because I didn&#8217;t take 5 minutes to check about something that could be wrong, I ended up costing hours worth of time.</p>
<p>It&#8217;s not mentioned explicitly but it is implied that the vices went away after the quality program was introduced.  While workers were embarrassed to be working at the plant before, they now were proud to tell  friends where they worked.</p>
<blockquote><p>In ancient times, brick makers, engravers, and other artisans used a symbol to mark the things they created to show that they were the makers.  The symbol that each one used was his &#8220;character.&#8221;  The value of the work was in proportion to the skill with which the object was made.  And only if the quality of the work was high was the character esteemed.  In other words, the quality of the person and his work gave value to his credentials.  If the work was good, so was the character.  If it was bad, then the character was viewed as poor.<br />
- &#8220;Becoming a Person of Influence&#8221; by John C. Maxwell &#038; Jim Dornan</p></blockquote>
<p>This is why the morale and esteem of the workers improved once quality became the focus.  Your character is revealed in the work you do and vice versa.  If you are producing shoddy work, your character is being revealed as such.</p>
<p>In programming, quality does not mean taking a stand over something trivial such as whether to use tabs or spaces for indentation.  Quality means being consistent in your work.  It means following design principles that will save time and effort down the road.  It means doing things right the first time so you don&#8217;t need to correct them later.</p>
<p>Always do things in a quality manner.  Never compromise.  For if you do, you are compromising your character.</p>
<p>&#8211;</p>
<p><a href="http://www.thisamericanlife.org/radio-archives/episode/403/nummi">This American Life episode about NUMMI</a><br />
<a href="https://www.amazon.com/dp/0785288392?tag=mattmccormick-20&#038;camp=0&#038;creative=0&#038;linkCode=as1&#038;creativeASIN=0785288392&#038;adid=1KHH40EYM22GBT702C63&#038;">Becoming a Person of Influence</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mattmccormick.ca/2010/04/27/never-compromise-quality/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to easily create Models and Table Relationships in Zend Framework</title>
		<link>http://mattmccormick.ca/2010/04/24/how-to-easily-create-models-and-table-relationships-in-zend-framework/</link>
		<comments>http://mattmccormick.ca/2010/04/24/how-to-easily-create-models-and-table-relationships-in-zend-framework/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 19:06:02 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[models]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[table relationships]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://mattmccormick.ca/?p=52</guid>
		<description><![CDATA[When I first started using Zend Framework, I was so frustrated when trying to figure out how to get information from the database.  I fought against the framework for the longest time.  Instead of working with it, I would write the SQL and then simply query the database to get the data back [...]]]></description>
			<content:encoded><![CDATA[<p>When I first started using Zend Framework, I was so frustrated when trying to figure out how to get information from the database.  I fought against the framework for the longest time.  Instead of working with it, I would write the SQL and then simply query the database to get the data back as an array of objects.</p>
<p>Later on I learned at just how powerful Zend Framework can be when it comes to retrieving models.  It is actually easier and more fun to do things in the &#8220;Zend&#8221; way.</p>
<p>This is the post I wish I had read before spending hours going about things the wrong way.</p>
<p>I&#8217;m using Zend Framework for a project which has videos, users (each user can have many videos) and tags (many tags to many videos).  This example will show you how to setup your models correctly:</p>
<p><strong>/application/models/DbTable/Videos.php</strong></p>
<pre class="brush: php">class Model_DbTable_Videos extends Zend_Db_Table_Abstract
{
	protected $_name = &#039;videos&#039;;	// database table name
	protected $_rowClass = &#039;Model_Row_Video&#039;;	// row class for extending
	protected $_dependentTables = array(&#039;Model_DbTable_VideoTag&#039;);	// videos depends on the many-to-many join table for tags

	protected $_referenceMap = array(
		&#039;User&#039; =&gt; array(
			&#039;columns&#039; =&gt; &#039;user_id&#039;,	// the column in the &#039;videos&#039; table which is used for the join
			&#039;refTableClass&#039; =&gt; &#039;users&#039;,	// the users table name
			&#039;refColumns&#039; =&gt; &#039;id&#039;	// the primary key of the users table
		)
	);
}</pre>
<p><strong>/application/models/DbTable/User.php</strong></p>
<pre class="brush: php">class Model_DbTable_Users extends Zend_Db_Table_Abstract
{
	protected $_name = &#039;users&#039;;
	protected $_rowClass = &#039;Model_Row_User&#039;;
	protected $_dependentTables = array(&#039;Model_DbTable_Videos&#039;);
}</pre>
<p><strong>/application/models/DbTable/Tags.php</strong></p>
<pre class="brush: php">class Model_DbTable_Tags extends Zend_Db_Table_Abstract
{
    protected $_name = &#039;tags&#039;;
    protected $_rowsetClass = &#039;Model_Rowset_Tags&#039;;
}</pre>
<p><strong>/application/models/DbTable/VideoTag.php</strong> (the join table for many-to-many relationship)</p>
<pre class="brush: php">class Model_DbTable_VideoTag extends Zend_Db_Table_Abstract
{
    protected $_name = &#039;video_tag&#039;;
    protected $_referenceMap = array(
		&#039;Video&#039; =&gt; array(
			&#039;columns&#039; =&gt; &#039;video_id&#039;,
			&#039;refTableClass&#039; =&gt; &#039;Model_DbTable_Videos&#039;,
			&#039;refColumns&#039; =&gt; &#039;id&#039;
   		),
   		&#039;Tag&#039; =&gt; array(
   			&#039;columns&#039; =&gt; &#039;tag_id&#039;,
   			&#039;refTableClass&#039; =&gt; &#039;Model_DbTable_Tags&#039;,
   			&#039;refColumns&#039; =&gt; &#039;id&#039;
   		)
	);
}</pre>
<p>The protected fields allow you to tell the framework the setup of the tables.  You can also extend the Row on Rowset by simply setting the $_rowClass or $_rowsetClass field.</p>
<p>In Model_DbTable_Videos, you see I have specified the $_rowClass field.  This means any row returned will be an object of Model_Row_Video.  In the class Model_Row_Video, I have added extra methods for easily retrieving the user of the video and tags belonging to that video:</p>
<p><strong>/application/models/Row/Video.php</strong></p>
<pre class="brush: php">
class Model_Row_Video extends Zend_Db_Table_Row_Abstract
{
	private $tags = null;
	private $user = null;

	/**
	 * @return Model_Row_User
	 */
	public function getUser()
	{
		if (!$this-&gt;user) {
			$this-&gt;user = $this-&gt;findParentRow(&#039;Model_DbTable_Users&#039;);
		}

		return $this-&gt;user;
	}

	/**
	 * @return Model_Rowset_Tags
	 */
	public function getTags()
	{
		if (!$this-&gt;tags) {
			$this-&gt;tags = $this-&gt;findManyToManyRowset(
				&#039;Model_DbTable_Tags&#039;,	// match table
				&#039;Model_DbTable_VideoTag&#039;);	// join table
		}

		return $this-&gt;tags;
	}
}
</pre>
<p>Because I have all the relationships setup, I simply need to call findParentRow() or findManyToManyRowset() to get the Row or Rowset of a related record.</p>
<p>Here is an example for the Rowset:</p>
<p><strong>/application/models/Rowset/Tags.php</strong></p>
<pre class="brush: php">
class Model_Rowset_Tags extends Zend_Db_Table_Rowset_Abstract
{
	/**
	 * @return array the tags in an array
	 */
	public function getAsArray()
	{
		$tags = array();

		while ($this-&gt;valid()) {
			$tag = $this-&gt;current();
			$tags[] = $tag-&gt;name;  // the actual tag name
			$this-&gt;next();
		}

		$this-&gt;rewind();

		return $tags;
	}
}
</pre>
<p>So to get the tags of the video with ID 23 all I need to do now is simply:</p>
<pre class="brush: php">
$tblVideo = new Model_DbTable_Videos();
$video = $tblVideo-&gt;find(23)-&gt;current();  // returns Model_Row_Video
$tagsArr = $video-&gt;getTags()-&gt;getAsArray();
</pre>
<p>Working with Zend Framework becomes very easy and pleasurable once you follow their setup.</p>
<p>Refer to the <a href="http://framework.zend.com/manual/en/zend.db.html">Zend_Db section of the manual</a> for more information about working with the database.</p>
]]></content:encoded>
			<wfw:commentRss>http://mattmccormick.ca/2010/04/24/how-to-easily-create-models-and-table-relationships-in-zend-framework/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>I Don&#8217;t Want to be a Code Monkey</title>
		<link>http://mattmccormick.ca/2009/11/30/i-dont-want-to-be-a-code-monkey/</link>
		<comments>http://mattmccormick.ca/2009/11/30/i-dont-want-to-be-a-code-monkey/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 21:24:10 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://mattmccormick.ca/?p=6</guid>
		<description><![CDATA[&#8220;I don&#8217;t want to be a code monkey.&#8221;  I&#8217;ve heard a few friends say this who are involved in programming.  I don&#8217;t get it.
Wikipedia says that a code monkey is someone &#8220;who writes computer code for a living.&#8221;  That&#8217;s pretty broad.  I assume a code monkey refers to someone who mindlessly takes orders.  In that [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&#8220;I don&#8217;t want to be a code monkey.&#8221;  I&#8217;ve heard a few friends say this who are involved in programming.  I don&#8217;t get it.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Wikipedia says that a code monkey is someone &#8220;who writes computer code for a living.&#8221;  That&#8217;s pretty broad.  I assume a code monkey refers to someone who mindlessly takes orders.  In that case, a code monkey must be someone who stands behind a counter, smiles and says &#8220;Would you like to supersize that IF statement?  You can get an extra variable for just 50 cents more!&#8221;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Perhaps it is more than that though.  Perhaps these people just don&#8217;t want to take orders and want to have creative control over their work.  Fools!  If you are not fulfilling orders, you are not providing value and you are not getting paid.  No matter what you do, you will always have to take orders and serve.  Even a founder of a company needs to fulfill the orders of his customers.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">In my programming career I always feel I have creative control over my work.  I have worked with both technical and non-technical clients, on large systems and small and all situations call for creative input.  Without creativity, programming would be boring.  Top programmers can command 6 figure salaries.  Surely, monkeys do not get paid that well.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">What if you work for a non-technical manager who just says what he wants done?</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">What&#8217;s wrong with that I say.  If the person you&#8217;re working for isn&#8217;t technically minded then you have complete freedom to do the work in whatever way you choose.  You can try out new frameworks or programming languages.  You can use different development methodologies.  It doesn&#8217;t matter as long as it gets the job done.  There are differences between working for a technical and non-technical manager and they generally balance out.  With a non-technical manager, however, you are the expert.  They hired you because they don&#8217;t know what you know.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Just because you program doesn&#8217;t mean you are a code monkey.  You have a choice.  You will end up being a code monkey if you stop learning after college.</div>
<p>&#8220;I don&#8217;t want to be a code monkey.&#8221;  I&#8217;ve heard a few friends say this who are involved in programming.  I don&#8217;t get it.</p>
<p>Wikipedia says that a code monkey is someone &#8220;who writes computer code for a living.&#8221;  That&#8217;s pretty broad.  I assume a code monkey refers to someone who mindlessly takes orders.  In that case, a code monkey must be someone who stands behind a counter, smiles and says &#8220;Would you like to supersize that IF statement?  You can get an extra variable for just 50 cents more!&#8221;</p>
<p>Perhaps it is more than that though.  Perhaps these people just don&#8217;t want to take orders and want to have creative control over their work.  Fools!  If you are not fulfilling orders, you are not providing value and you are not getting paid.  No matter what you do, you will always have to take orders and serve.  Even a founder of a company needs to fulfill the orders of his customers.</p>
<p>I always feel I have creative control over my work.  I have worked with both technical and non-technical clients, on large systems and small and all situations call for creative input.  Without creativity, programming would be boring.  Top programmers can command 6 figure salaries.  Surely, monkeys do not get paid that well.</p>
<p>What if you work for a non-technical manager who just says what he wants done?</p>
<p>What&#8217;s wrong with that I say.  If the person you&#8217;re working for isn&#8217;t technically minded then you have complete freedom to do the work in whatever way you choose.  You can try out new frameworks or programming languages.  You can use different development methodologies.  It doesn&#8217;t matter as long as it gets the job done.  There are differences between working for a technical and non-technical manager and they generally balance out.  With a non-technical manager, however, <strong>you </strong>are the expert.  They hired you because they don&#8217;t know what you know.</p>
<p>Just because you program doesn&#8217;t mean you are a code monkey.  You have a choice.  You will end up being a code monkey if you stop learning after college.</p>
]]></content:encoded>
			<wfw:commentRss>http://mattmccormick.ca/2009/11/30/i-dont-want-to-be-a-code-monkey/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
