<?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"
	>

<channel>
	<title>Add It Up Development Blog &#187; Decisions</title>
	<atom:link href="http://blog.letsadditup.com/category/decisions/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.letsadditup.com</link>
	<description>Building a PHP financial management app, one line of code at a time</description>
	<pubDate>Thu, 11 Dec 2008 12:50:28 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Controller, Model, and URL design</title>
		<link>http://blog.letsadditup.com/2008/08/08/controller-model-and-url-design/</link>
		<comments>http://blog.letsadditup.com/2008/08/08/controller-model-and-url-design/#comments</comments>
		<pubDate>Fri, 08 Aug 2008 16:14:37 +0000</pubDate>
		<dc:creator>Matthew Pennell</dc:creator>
		
		<category><![CDATA[CodeIgniter]]></category>

		<category><![CDATA[Decisions]]></category>

		<category><![CDATA[design]]></category>

		<category><![CDATA[mvc]]></category>

		<category><![CDATA[orm]]></category>

		<category><![CDATA[routing]]></category>

		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://blog.letsadditup.com/?p=22</guid>
		<description><![CDATA[What&#8217;s in a name?
Like I would imagine many programmers, I have a tendency to get a little anal about naming my Controllers and Models. Combine this with the default behaviour of CodeIgniter to parse the URL segments into controller/function/id parts, and it all begins to get very messy unless some careful thought is put into [...]]]></description>
			<content:encoded><![CDATA[<p>What&#8217;s in a name?</p>
<p>Like I would imagine many programmers, I have a tendency to get a little anal about naming my Controllers and Models. Combine this with the default behaviour of CodeIgniter to parse the URL segments into controller/function/id parts, and it all begins to get very messy unless some careful thought is put into this stage of a project.</p>
<p>For my finance application there are a few obvious &#8216;pages&#8217; needed. A user will want to view their list of accounts, or an individual account. Using the default structure, a sensible URL design might be:</p>
<ul>
<li><strong>/accounts</strong> to list all accounts</li>
<li><strong>/account/details/12345678</strong> to view the transactions of a particular account</li>
</ul>
<p>The latter URL would require a Controller named &#8216;Account&#8217; containing a method named &#8216;Details&#8217;. That all sounds okay so far, but what happens when you throw Models and ORM into the mix?</p>
<p>I plan to use a hand-rolled ORM solution to handle the database interaction within the app, which would mean for the &#8216;accounts&#8217; table, my Model class would be named&#8230; &#8216;Account&#8217;. And you can&#8217;t instantiate two separate classes with the same name. Problem.</p>
<p>Assuming (and sticking with convention over configuration) that the Models have to be named correctly (&#8217;Account&#8217; for the accounts, &#8216;User&#8217; for the users, and so on), how should I decide on the naming of my Controllers?</p>
<p>As I see it, there are two options:</p>
<ol>
<li>Pick a convention for Controllers and stick to it. For example: account_controller, user_controller - I can even use <a href="http://codeigniter.com/user_guide/general/routing.html">the URL routing feature</a> to redirect my original choice for URLs to the newly named controllers, although in my experience relying on routing can start to get messy.</li>
<li>Come up with a new design for my URLs and reflect that in my Controller names. This could be anything - <strong>/show/me/12345678</strong>, <strong>/list/transactions/from/12345678</strong> - the possibilities are endless. This option has the benefit of avoiding complicated routing rules, but could prove less intutive to write and maintain.</li>
</ol>
<p>I&#8217;m leaning toward Option 2, based on a combination of disliking excessive routing and loving <a href="http://blog.welldesignedurls.org/">beautiful URL design</a>. I&#8217;d love to hear what conclusions other MVC application developers have come to, though.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.letsadditup.com/2008/08/08/controller-model-and-url-design/feed/</wfw:commentRss>
		</item>
		<item>
		<title>To Parse or not to Parse, that is the question</title>
		<link>http://blog.letsadditup.com/2008/07/12/to-parse-or-not-to-parse-that-is-the-question/</link>
		<comments>http://blog.letsadditup.com/2008/07/12/to-parse-or-not-to-parse-that-is-the-question/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 19:20:04 +0000</pubDate>
		<dc:creator>Matthew Pennell</dc:creator>
		
		<category><![CDATA[CodeIgniter]]></category>

		<category><![CDATA[Decisions]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Add new tag]]></category>

		<category><![CDATA[html]]></category>

		<category><![CDATA[magento]]></category>

		<category><![CDATA[mvc]]></category>

		<category><![CDATA[parser]]></category>

		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://blog.letsadditup.com/?p=17</guid>
		<description><![CDATA[When I first began to consider building a web application using CodeIgniter, one of the key aspects I had in my mind was to keep the HTML template files (the View in Model-View-Controller) as PHP-free as humanly possible.
At that time, I was planning to develop an e-commerce application (this was before the launch of Magento), [...]]]></description>
			<content:encoded><![CDATA[<p>When I first began to consider building a web application using <a href="http://codeigniter.com">CodeIgniter</a>, one of the key aspects I had in my mind was to keep the HTML template files (the View in <a href="en.wikipedia.org/wiki/Model-view-controller">Model-View-Controller</a>) as PHP-free as humanly possible.</p>
<p>At that time, I was planning to develop an e-commerce application (this was before the launch of <a href="http://www.magentocommerce.com/">Magento</a>), so my reasoning was that a distributed web app should make it easy for programmers to work on backend code while allowing designers to hack on the templates without having to understand a bunch of complicated PHP statements.</p>
<h3>CodeIgniter&#8217;s Template Parser Class</h3>
<p>To pass data from the Controller to the View in CodeIgniter, you would normally load the view template and pass in an array of data:</p>
<pre>$this-&gt;load-&gt;view('my_template', array(</pre>
<pre>    'page_name' =&gt; 'About Us',</pre>
<pre>    'page_content' =&gt; 'Hey, we are a great company!'</pre>
<pre>));</pre>
<p>The array of data is transformed into local variables for use within the template:</p>
<pre>&lt;h1&gt;&lt;?= $page_name ?&gt;&lt;/h1&gt;</pre>
<pre>&lt;p&gt;&lt;?= $page_content ?&gt;&lt;/p&gt;</pre>
<p>That&#8217;s all very well with basic variables, but when it comes to arrays your template can quickly become cluttered with nested if, else, and foreach statements - and that can be confusing for non-technical designers or purely front-end (HTML/CSS) developers.</p>
<p>The <a title="The Parser Class on the CI user guide" href="http://codeigniter.com/user_guide/libraries/parser.html">Template Parser Class</a> replaces those PHP echo statements with special variables that, in theory, are easier to understand:</p>
<pre>&lt;h1&gt;{page_title}&lt;/h1&gt;</pre>
<pre>&lt;p&gt;{page_content}&lt;/p&gt;</pre>
<pre>&lt;ul&gt;</pre>
<pre>    {link_list}</pre>
<pre>        &lt;li&gt;{link_description}&lt;/li&gt;</pre>
<pre>    {/link_list}</pre>
<pre>&lt;/ul&gt;</pre>
<p>For simple strings and basic arrays, the Parser class is easy to use - but once you start wanting to use different HTML depending on the values of your data, it can get messy. With embedded PHP in the templates, it is easy to throw a little logic into the View file - if it&#8217;s this then add that class name - but following a strict &#8220;No PHP&#8221; rule can have you jumping through hoops if your HTML isn&#8217;t architected to cope with displaying different types of data in the same way.</p>
<p>Of course, the whole point of MVC is that you <em>shouldn&#8217;t</em> be putting logic in your Views, so there really shouldn&#8217;t be any major hurdles in solely using the Parser class - but it&#8217;s going to take me a little while to get used to thinking that way.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.letsadditup.com/2008/07/12/to-parse-or-not-to-parse-that-is-the-question/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Prioritising features: bit by bit, or all at once?</title>
		<link>http://blog.letsadditup.com/2008/07/08/prioritising-features-bit-by-bit-or-all-at-once/</link>
		<comments>http://blog.letsadditup.com/2008/07/08/prioritising-features-bit-by-bit-or-all-at-once/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 14:09:29 +0000</pubDate>
		<dc:creator>Matthew Pennell</dc:creator>
		
		<category><![CDATA[Decisions]]></category>

		<category><![CDATA[auth]]></category>

		<category><![CDATA[controller]]></category>

		<category><![CDATA[database]]></category>

		<category><![CDATA[model]]></category>

		<guid isPermaLink="false">http://blog.letsadditup.com/?p=5</guid>
		<description><![CDATA[With a two-page functional specification completed, I am almost ready to make with the code, but first I need to decide on the most efficient order in which to develop features.
As the final application will be for multiple users, there will necessarily be a significant amount of user account creation, maintenance, and security involved - [...]]]></description>
			<content:encoded><![CDATA[<p>With a two-page functional specification completed, I am almost ready to make with the code, but first I need to decide on the most efficient order in which to develop features.</p>
<p>As the final application will be for multiple users, there will necessarily be a significant amount of user account creation, maintenance, and security involved - but the core of the app is going to be the accounts, transactions, and reporting functionality. Should I develop from the outside in, and build the authorisation system first? Or build it from the inside out, and get the &#8216;fun&#8217; stuff working initially - the transaction interpreter and categorisation engine - and then wrap the authorisation bits around that?</p>
<p>Both options are attractive. It would be great to get stuck straight into the meat of the application - after all, I&#8217;m the only one who will be using it for the forseeable future - but then one has to consider that locking down database access to an authorised user is likely to affect every database model I write.</p>
<p>On the other hand, starting with the registration and authorisation sections could take quite some time - I don&#8217;t want to kill my enthusiasm for the project that early on!</p>
<p>I think I&#8217;m probably going to start with the interesting bits first, on the assumption that the user auth stuff can be abstracted to a simple call in the constructor of every controller (and won&#8217;t require major re-writing of the database models later on).</p>
<p>If anyone has any experience that says otherwise, of course, please let me know! <img src='http://blog.letsadditup.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.letsadditup.com/2008/07/08/prioritising-features-bit-by-bit-or-all-at-once/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Is PHP4 worth it any more?</title>
		<link>http://blog.letsadditup.com/2008/07/07/is-php4-worth-it-any-more/</link>
		<comments>http://blog.letsadditup.com/2008/07/07/is-php4-worth-it-any-more/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 15:04:18 +0000</pubDate>
		<dc:creator>Matthew Pennell</dc:creator>
		
		<category><![CDATA[Decisions]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[activerecord]]></category>

		<category><![CDATA[CodeIgniter]]></category>

		<category><![CDATA[php4]]></category>

		<category><![CDATA[php5]]></category>

		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://blog.letsadditup.com/?p=4</guid>
		<description><![CDATA[A week or so ago, I posed a question on Twitter:
If you were going to build a PHP application for use by others, would you even bother making it PHP4 compatible any more?
Responses were - with one exception - unanimous, with most people citing hosting as a key reason. Rachel Andrew, edgeofmyseat:
PHP5 all the way [...]]]></description>
			<content:encoded><![CDATA[<p>A week or so ago, <a href="http://twitter.com/matthewpennell/statuses/844042373">I posed a question</a> on Twitter:</p>
<blockquote><p>If you were going to build a PHP application for use by others, would you even bother making it PHP4 compatible any more?</p></blockquote>
<p>Responses were - with <a title="Kerri Hicks disagreed" href="http://twitter.com/kerri9494/statuses/844046820">one exception</a> - unanimous, with most people citing hosting as a key reason. <a href="http://edgeofmyseat.com/">Rachel Andrew, edgeofmyseat</a>:</p>
<blockquote><p>PHP5 all the way &#8230; more apps that require PHP5 means more people asking for PHP5 on shared hosting.</p></blockquote>
<p><a href="http://dotjay.co.uk/">Jon Gibbins</a> agreed:</p>
<blockquote><p>Not worth the effort now I think. I suspect many hosting services to be upgrading now that PHP 4 is end of life.</p></blockquote>
<p>And <a href="http://www.studio24.net/">Simon Jones, studio24</a>:</p>
<blockquote><p>Encourage people to look forward not back.</p></blockquote>
<h3>CodeIgniter and PHP5</h3>
<p>While there are a fair few PHP frameworks that only run on PHP5, <a href="http://www.codeigniter.com/">CodeIgniter</a> is not one of them - in fact, the only minor benefit one can obtain from using PHP5 is that it allows you to chain methods together when using its <a href="http://codeigniter.com/user_guide/database/active_record.html">Active Record class</a>:</p>
<pre>$result = $this-&gt;db-&gt;select('id, name')-&gt;from('mytable')-&gt;where('name', 'Bob')-&gt;get();</pre>
<p>So no real benefit to be gained in that respect. What PHP5 does offer, though, is <a title="List of new PHP5 functions on php.net" href="http://www.php.net/manual/en/migration5.functions.php">many new functions</a>, a completely <a href="http://www.php.net/manual/en/language.oop5.php">new object model</a>, and various other <a title="Overloading in PHP5" href="http://http://uk.php.net/manual/en/language.oop5.overloading.php">cool</a> <a href="http://uk3.php.net/manual/en/ref.filter.php">things</a>.</p>
<p>At the moment I&#8217;m leaning heavily in favour of going with PHP5 - as someone else noted, it&#8217;s going to be much easier to port code from PHP5 to PHP6, than from 4 to 6 - but I&#8217;m still open to persuasion if anyone thinks differently.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.letsadditup.com/2008/07/07/is-php4-worth-it-any-more/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
