<?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>Bradley Holt &#187; MVC</title>
	<atom:link href="http://bradley-holt.com/tag/mvc/feed/" rel="self" type="application/rss+xml" />
	<link>http://bradley-holt.com</link>
	<description></description>
	<lastBuildDate>Thu, 17 May 2012 01:04:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>The MVC Paradox</title>
		<link>http://bradley-holt.com/2012/04/the-mvc-paradox/</link>
		<comments>http://bradley-holt.com/2012/04/the-mvc-paradox/#comments</comments>
		<pubDate>Thu, 05 Apr 2012 17:27:23 +0000</pubDate>
		<dc:creator>Bradley Holt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Domain-Driven Design]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[Slim]]></category>
		<category><![CDATA[Software Design]]></category>
		<category><![CDATA[Web Application Frameworks]]></category>

		<guid isPermaLink="false">http://bradley-holt.com/?p=1503</guid>
		<description><![CDATA[Use of the Model View Controller (MVC) design pattern is generally accepted as a best practice in modern web applications. Like all design patterns, MVC is a reusable solution to a common problem. The MVC pattern is intended to address the following concerns: Support for multiple types of clients Reduce duplicate code when supporting multiple [...]]]></description>
			<content:encoded><![CDATA[<p>Use of the Model View Controller (MVC) design pattern is generally accepted as a best practice in modern web applications. Like all design patterns, MVC is a reusable solution to a common problem. The MVC pattern is intended to address the following concerns:</p>
<ol>
<li>Support for multiple types of clients</li>
<li>Reduce duplicate code when supporting multiple types of clients</li>
<li>Isolating domain logic from the user interface</li>
</ol>
<p>Note that items 2 and 3 are both dependent on item 1. <em>Support for multiple types of clients is the single driving force behind the MVC design pattern.</em> Following are some examples of client types:</p>
<ul>
<li>Web Browsers</li>
<li>API Clients</li>
<li>Admin Processes (e.g. CLI, cron, daemon)</li>
<li>Unit Tests</li>
<li>Native GUI</li>
</ul>
<p>Realistically, how many of these different client types do you need to support? If you&#8217;re taking a RESTful approach, then <a href="http://caines.ca/blog/programming/the-sun-is-setting-on-rails-style-mvc-frameworks/">Web Browsers and API Clients can be combined into one type of client</a>, which we can just call User Agents. Likely you&#8217;re not building a Native GUI. This leaves you with the following three types of clients to support:</p>
<ul>
<li>User Agents</li>
<li>Admin Processes</li>
<li>Unit Tests</li>
</ul>
<p>Do you really need to use the MVC design pattern in order to support User Agents, Admin Processes, and Unit Tests? Likely not. That&#8217;s not to say that there aren&#8217;t benefits to isolating domain logic from the user interface. However, if you don&#8217;t need to support multiple types of clients you should really question your use of the MVC design pattern. There are many approaches one can take to separating the domain logic and the user interface, of which MVC is just one.</p>
<p>This bring me to The MVC Paradox.<em> Modern MVC web frameworks inadvertently encourage the coupling of domain logic and user interface.</em> If you don&#8217;t need to support multiple types of clients, then decoupling the domain logic from the user interface is the only reason left to use the MVC design pattern.</p>
<p>Modern MVC web frameworks often involve a lot of boilerplate code just to support the primary client type of User Agents. This boilerplate code typically does little to help with supporting the other client types of Admin Processes and Unit Tests. As a result of the overhead introduced by this extra boilerplate code, developers often find themselves creating Fat Controllers (a side-effect of The MVC Paradox). Controllers take on too many responsibilities, both vertically and horizontally. Vertically, Controllers start to handle domain logic that should be pushed down to the Model layer. Horizontally, multiple concerns get stuffed into a handful of Controllers. These different horizontal concerns should be separated out into multiple Controllers (the Single Responsibility Principle). The overhead introduced by modern MVC web frameworks leads directly to these problems.</p>
<p>In contrast, take a look at the <a href="http://www.slimframework.com/">Slim PHP 5 micro framework</a>. While not a completely <a href="http://www.developerfusion.com/article/141194/evaluating-rest-frameworks-part-1-a-maturity-model/">RESTful framework</a>, it does a pretty good job of addressing the concerns I&#8217;ve laid out in this post. Here is the &#8220;Hello world&#8221; example from Slim&#8217;s homepage:</p>
<pre><code class="php">&lt;?php
require 'Slim/Slim.php';
$app = new Slim();
$app-&gt;get('/hello/:name', function ($name) {
    echo "Hello, $name!";
});
$app-&gt;run();
?&gt;</code></pre>
<p>There is very little boilerplate code involved in handling a User Agent&#8217;s request. Minting and handling new routes is incredibly simple. Placing your entire front-end application layer in one file may seem absurd at first. However, it has the nice side-effect of making it painfully obvious if you start to handle domain logic outside of your Model layer or if one route is doing too many things. If your front-end application is large enough, then you can <a href="http://www.slimframework.com/read/how-to-organize-a-large-slim-framework-application">organize your routes into separate files</a>.</p>
<p>This post is not intended to discourage you from using an MVC web framework. There are certainly times when such a framework is useful. As with any technology decision, carefully consider what problem you&#8217;re trying to solve and what technology will best address your problem set. Sometimes your technology choice can undermine the very purpose of using that technology in the first place, as is the case with The MVC Paradox.</p>
]]></content:encoded>
			<wfw:commentRss>http://bradley-holt.com/2012/04/the-mvc-paradox/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Vermont Startup Looking for PHP Developer</title>
		<link>http://bradley-holt.com/2011/04/vermont-startup-looking-for-php-developer/</link>
		<comments>http://bradley-holt.com/2011/04/vermont-startup-looking-for-php-developer/#comments</comments>
		<pubDate>Wed, 20 Apr 2011 16:39:52 +0000</pubDate>
		<dc:creator>Bradley Holt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[BTV]]></category>
		<category><![CDATA[btvphp]]></category>
		<category><![CDATA[jobs]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Vermont]]></category>

		<guid isPermaLink="false">http://bradley-holt.com/?p=1066</guid>
		<description><![CDATA[A new startup called Kohort is looking to add a PHP developer to their team here in Burlington, Vermont. The job description is as follows: We&#8217;re a new startup with some venture backing. We&#8217;re looking to add an experienced developer to help us out for the next five weeks (and possibly more). Qualifications are: experienced [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.kohort.com/"><img class="alignright" src="http://www.crunchbase.com/assets/images/resized/0013/1052/131052v1-max-150x150.png" border="0" alt="Kohort" width="150" height="56" /></a>A new startup called <a href="http://www.kohort.com/">Kohort</a> is looking to add a PHP developer to their team here in Burlington, Vermont. The job description is as follows:</p>
<blockquote><p>We&#8217;re a new startup with some venture backing. We&#8217;re looking to add an experienced developer to help us out for the next five weeks (and possibly more). Qualifications are:</p>
<ul>
<li>experienced PHP hacker (5+ years)</li>
<li>full understanding of MVC frameworks (codeignitor, cake, symfony, zend, kohana or the like)</li>
<li>comfortable with the LAMP stack</li>
<li>understanding of git</li>
<li>able to plug into a new project and start coding in under a day</li>
</ul>
<p>You&#8217;ll be working with a team of 6 developers in downtown Burlington.</p></blockquote>
<p>Kohort was featured in TechCrunch the other day for <a href="http://techcrunch.com/2011/04/18/kohort-3-million-seed/">raising a “seed” round of $3 million</a>. If you&#8217;re interested, contact Steve Blood. You can find Steve&#8217;s email address in <a href="http://groups.google.com/group/burlington-vt-php/browse_thread/thread/48f321eb631e12d4">this thread</a>, or let me know and I can put you in touch with him.</p>
]]></content:encoded>
			<wfw:commentRss>http://bradley-holt.com/2011/04/vermont-startup-looking-for-php-developer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework 2.0 and PHP 5.3 Web Applications SXSW Interactive Panel</title>
		<link>http://bradley-holt.com/2010/08/zend-framework-2-0-and-php-5-3-web-applications-sxsw-interactive-panel/</link>
		<comments>http://bradley-holt.com/2010/08/zend-framework-2-0-and-php-5-3-web-applications-sxsw-interactive-panel/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 17:01:13 +0000</pubDate>
		<dc:creator>Bradley Holt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SXSW]]></category>
		<category><![CDATA[SXSWi]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://bradley-holt.com/?p=751</guid>
		<description><![CDATA[I have submitted a panel on Zend Framework 2.0 and PHP 5.3 Web Applications for the 2011 SXSW Interactive Festival. Please consider giving this panel your vote. From the panel&#8217;s description: Zend Framework is a free/open source web application framework. It can be used either as a component library or as a full-stack Model–View–Controller (MVC) [...]]]></description>
			<content:encoded><![CDATA[<p>I have submitted a panel on <a href="http://panelpicker.sxsw.com/ideas/view/6336">Zend Framework 2.0 and PHP 5.3 Web Applications</a> for the 2011 <a href="http://sxsw.com/interactive">SXSW Interactive Festival</a>. Please consider giving this panel your vote. From the panel&#8217;s description:</p>
<blockquote><p>Zend Framework is a free/open source web application framework. It can  be used either as a component library or as a full-stack  Model–View–Controller (MVC) framework. As compared to its 1.x  counterparts, Zend Framework 2.0 is easier to learn, trivially simple to  extend, and more performant. It is also easier to use just specific  parts of the framework as needed. We will explore the many features of  Zend Framework 2.0 including its tooling, functional testing, form,  database, pagination, date, markup, navigation, and MVC components.   Zend Framework 2.0 takes advantages of several new features in PHP 5.3  including closures/lambdas, namespaces, and late static binding. We will  explore some of these new features to understand why PHP 5.3 is a  requirement for Zend Framework 2.0 and how you can leverage these new  features within your application itself. An example web application will  be provided that you can use as a reference when building your own Zend  Framework web application.</p></blockquote>
<p>For those wondering, Zend Framework 2.0 is not out yet but SXSW is not until next March and Zend Framework 2.0 will most likely be released by then. The description above is based on the <a href="http://framework.zend.com/wiki/display/ZFDEV2/Zend+Framework+2.0+Requirements">Zend Framework 2.0 Requirements</a> and discussions on the Zend Framework contributors mailing list.</p>
]]></content:encoded>
			<wfw:commentRss>http://bradley-holt.com/2010/08/zend-framework-2-0-and-php-5-3-web-applications-sxsw-interactive-panel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MVC in Zend Framework</title>
		<link>http://bradley-holt.com/2010/02/mvc-in-zend-framework/</link>
		<comments>http://bradley-holt.com/2010/02/mvc-in-zend-framework/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 17:51:37 +0000</pubDate>
		<dc:creator>Bradley Holt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://bradley-holt.com/?p=573</guid>
		<description><![CDATA[In my previous post in this series we looked at how Zend Framework applications can be bootstrapped. We saw the configuration file (application/configs/application.ini) and the Bootstrap class (in application/Bootstrap.php) from a demo blogging application, Postr. What happens once your application is bootstrapped and run? That&#8217;s where Zend Framework&#8217;s routing and Model-View-Controller (MVC) components come in [...]]]></description>
			<content:encoded><![CDATA[<p>In my <a href="http://bradley-holt.com/2010/01/bootstrapping-zend-framework-applications/">previous post</a> in this series we looked at how Zend Framework applications can be bootstrapped. We saw the configuration file (<a href="http://github.com/bradley-holt/postr/blob/master/application/configs/application.ini"><code>application/configs/application.ini</code></a>) and the <code>Bootstrap</code> class (in <a href="http://github.com/bradley-holt/postr/blob/master/application/Bootstrap.php"><code>application/Bootstrap.php</code></a>) from a demo blogging application, <a href="http://github.com/bradley-holt/postr">Postr</a>. What happens once your application is bootstrapped and run? That&#8217;s where Zend Framework&#8217;s routing and <a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">Model-View-Controller</a> (MVC) components come in (technically there are a few steps in-between, but we&#8217;ll come back to that in a future post).</p>
<dl>
<dt>Model</dt>
<dd>Your domain objects. There is no <code>Zend_Model</code> since your domain logic is specific to your application. However, there are some best practices that have emerged in the Zend Framework community including <a href="http://martinfowler.com/eaaCatalog/dataMapper.html">Data Mappers</a> (which I&#8217;ll talk about later).</dd>
<dd> See example Models in <a href="http://github.com/bradley-holt/postr/tree/master/application/models/"><code>application/models/</code></a></dd>
<dt>View</dt>
<dd>The presentation layer. The default implementation uses PHP templates called <em>view scripts</em>. View script files have a default suffix of <code>.phtml</code>. There should be no domain logic in your view scripts. By default, there is one view script per controller action (we&#8217;ll see what that means shortly).</dd>
<dd>See example Views in <a href="http://github.com/bradley-holt/postr/tree/master/application/views/"><code>application/views/</code></a></dd>
<dt>Controller</dt>
<dd>Connects the Model and the View. Each Controller contains one or more <em>actions</em>. The Controller&#8217;s job is to interpret input and pass it to the Model and also to provide Model data to the View.</dd>
<dd>See example Controllers in <a href="http://github.com/bradley-holt/postr/tree/master/application/controllers/"><code>application/controllers/</code></a></dd>
</dl>
<p>By default, Zend Framework will route requests based on URI segments as follows:</p>
<pre><code>:controller/:action[/:key/:value]</code></pre>
<p>A few example URIs:</p>
<ul>
<li><code>foo/bar</code> (foo controller, bar action)</li>
<li><code>foo/bar/baz/shaz</code> (foo controller, bar action, baz=shaz)</li>
</ul>
<p>It is possible to customize this routing in pretty much any way conceivable but I&#8217;d suggest sticking with the default routing until you have a good handle on how it works.</p>
<p>In my <a href="http://bradley-holt.com/2010/03/layouts-in-zend-framework/">next post</a> in this series I plan on taking a slight detour so that we can explore a very useful component, <code><a href="http://framework.zend.com/manual/en/zend.layout.html">Zend_Layout</a></code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://bradley-holt.com/2010/02/mvc-in-zend-framework/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

