<?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>Edward Yarnold</title>
	<atom:link href="http://www.edwardyarnold.co.uk/blog/feed" rel="self" type="application/rss+xml" />
	<link>http://www.edwardyarnold.co.uk/blog</link>
	<description>PHP &#38; MySQL Web Developer</description>
	<lastBuildDate>Wed, 04 Aug 2010 07:42:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Coding things the quick way &#8211; often a false economy</title>
		<link>http://www.edwardyarnold.co.uk/blog/coding-things-the-quick-way-often-false-economy</link>
		<comments>http://www.edwardyarnold.co.uk/blog/coding-things-the-quick-way-often-false-economy#comments</comments>
		<pubDate>Wed, 04 Aug 2010 07:37:41 +0000</pubDate>
		<dc:creator>Ed Yarnold</dc:creator>
				<category><![CDATA[Best Practice]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.edwardyarnold.co.uk/blog/?p=129</guid>
		<description><![CDATA[I have recently been tasked with making some changes to the central &#8216;library&#8217; of code that an E-Commerce platform is based on.  Essentially, the &#8216;models&#8217; for this application are all in a central, shared location, and all of the &#8216;installations&#8217; of the e-commerce platform have their own set of controllers and views that interact with [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently been tasked with making some changes to the central &#8216;library&#8217; of code that an E-Commerce platform is based on.  Essentially, the &#8216;models&#8217; for this application are all in a central, shared location, and all of the &#8216;installations&#8217; of the e-commerce platform have their own set of controllers and views that interact with these models.  The changes I am making involve making the deletion of products reversible; so instead of actually deleting products and associated assets, a flag is merely set in the database; is_deleted = 1.  This, at first glance, seems to be quite a simple task; alter the database tables to add the extra column in, and make a change to the central models in Model_Product::deleteProduct and any product &#8216;getter&#8217; functions, eg Model_Product::getProductsByCategoryId.  However, due to the way that the platform has been developed and individual customisations to the installations of that platform have been made, things aren&#8217;t quite so simple.</p>
<p><span id="more-129"></span>The idea of the &#8216;architect&#8217; of this system was that any interaction with databases or storage of data; ie the models; would be shared in the central library.  This would mean that changes such as the one I worked on with is_deleted = 1 would be simple and made in one place, and one place only.  A true implementation of the &#8216;Don&#8217;t Repeat Yourself (DRY)&#8217; principle.</p>
<p>The nature of this platform is that it is exactly that. A platform.  This typically means that no two implementations of the platform are identical, so to speak.  The platform is built upon and &#8216;extended&#8217; to do what the individual customers want from their online shop.  This sometimes means that custom product &#8216;getter&#8217; blocks of code are written.  Often, the &#8216;quick and easy&#8217; approach had been taken with these , and they had simply been added as standalone functions in the <strong>individual project&#8217;s library</strong>, called things such as getAllProductsFlaggedAsSpecial()  This obviously meant that when I implemented my is_deleted changes in the central library, and wasn&#8217;t aware of the custom nature of these custom product selectors, the sites that used those custom product selectors continued to display deleted products.  Big oops!</p>
<p>This now means that I will need to go through the individual implementations of the platform, search for any custom product SQL that is being built, and add the AND p.is_deleted = 0 in to them.</p>
<p>This whole problem got my thinking about how I would approach this issue (The need to build custom product getter functions in individual implementations of the platform), and here&#8217;s how I think I&#8217;d do it.</p>
<p>I think I would ensure that all custom product getter functions were in fact methods in an extension of the main Model class that then called a buildWhereClause method that added any global product SQL (eg AND is_deleted = 0) in, like this:</p>
<p><code><br />
class Model_Product extends Base_Model {<br />
...<br />
function buildWhereClause($sql) {<br />
return 'WHERE p.is_deleted = 0 AND '.$sql;<br />
}<br />
...<br />
}<br />
</code></p>
<p><code><br />
class MyShopNameModel_Product extends Model_Product {<br />
function getProductsFlaggedAsSpecial() {<br />
...<br />
$sql = "SELECT * FROM product ".$this-&gt;buildWhereClause('is_special = 1');<br />
...<br />
}<br />
}</code></p>
<p>Essentially, what I learnt here was that the developer to begin with that wrote these &#8216;quick functions&#8217; saved his or herself half an hour or so, but cost me (2-3 years later) a fair amount of time in debugging.  I think this is evidence that coding things the quick way and implementing a fast solution is often a false economy, and someone later in the life of the software will have to spend the time saved (and possibly more) to work around the disadvantages of the quick approach.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edwardyarnold.co.uk/blog/coding-things-the-quick-way-often-false-economy/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Some simple steps on the &#8220;front end&#8221; to reduce web page download time</title>
		<link>http://www.edwardyarnold.co.uk/blog/some-simple-steps-to-reduce-web-page-download-time</link>
		<comments>http://www.edwardyarnold.co.uk/blog/some-simple-steps-to-reduce-web-page-download-time#comments</comments>
		<pubDate>Wed, 14 Jul 2010 07:48:13 +0000</pubDate>
		<dc:creator>Ed Yarnold</dc:creator>
				<category><![CDATA[Optimisation]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.edwardyarnold.co.uk/blog/?p=125</guid>
		<description><![CDATA[A few years ago, page download time was a big focus for most web developers, as the majority of people connected to the internet were accessing through &#8220;dial up&#8221; connections, which we all remember for their awful connection noises and the horrific download speeds.  But with the development of faster internet connections in the developed [...]]]></description>
			<content:encoded><![CDATA[<p>A few years ago, page download time was a big focus for most web developers, as the majority of people connected to the internet were accessing through &#8220;dial up&#8221; connections, which we all remember for their awful connection noises and the horrific download speeds.  But with the development of faster internet connections in the developed world, the focus on page load times has been sacrificed for nice looking graphics, chunky javascript libraries and massive CSS files.  But there are some quick, simple steps that can be taken to keep all of the improved functionality and look of a web site but reduce the page load time a little.<br />
<span id="more-125"></span><br />
Before I get in to the tips themselves, here are a few basic rules of web site optimisation:</p>
<ul>
<li>HTTP requests are <a href="http://yuiblog.com/blog/2007/01/04/performance-research-part-2/">expensive in terms of time</a>.  Reducing the number speeds page load time.</li>
<li>Browsers can &#8211; and do &#8211; cache effectively.  Inline CSS and Javascript can&#8217;t be cached for later page requests.</li>
<li>Images can be optimised on the web without any major loss in visual quality.</li>
</ul>
<h2>Javascript Files</h2>
<h3>Minify Them!</h3>
<p>Firstly, remember that if you are including libraries such as jQuery, there are a few ways in which you can do so.  They offer a &#8220;minified&#8221; or &#8220;compressed&#8221; version, which is at least half the size in KB of the uncompressed version.  Given that you are extremely unlikely to need to ever modify the jQuery core, I don&#8217;t see any argument for including the full version of the library, and would choose to include the smaller, minified version every time.</p>
<p>If you have your own javascript files that are particularly hefty, you can minify those for production sites too, by using tools such as <a href="http://www.crockford.com/javascript/jsmin.html">JSMin</a>.  The only problem with doing this is you tend to need to maintain two versions of the file.  The minification process tends to be irreversible so you will need to keep a &#8220;development&#8221; copy of the javascript, just in case you need to make changes or additions in the future.</p>
<h3>Use a Content Delivery Network for your javascript libraries!</h3>
<p>If you want to go one step further, you can include libraries such as jQuery from &#8220;Content Delivery Networks&#8221;.  Here is what wikipedia defines a CDN as:</p>
<blockquote><p>A content delivery network or content distribution network (CDN) is a  system of computers containing copies of data, placed at various points  in a network so as to maximize bandwidth for access to the data from  clients throughout the network</p></blockquote>
<p>Put simply, CDNs are probably much more capable of delivering the javascript files to the web browser accessing your page quickly and reliably than your own server.  Additionally, remember that this means that the CDN is taking some of your bandwidth costs away &#8211; at least 50kb per new visitor.  An additional strange secondary advantage is that it is possible that the user has previously visited a page including the javascript library from the same CDN earlier in their internet browsing session, so it will already be cached in their machine, and will not need to be loaded for a second time.</p>
<p>If you are looking for a quick link to the Google Javascript CDN,  you can access it here:</p>
<p><a href="http://code.google.com/apis/ajaxlibs/">http://code.google.com/apis/ajaxlibs/</a></p>
<h3>Include them only when they are needed!</h3>
<p>Imagine that you have a &#8220;google map&#8221; page on your web site that integrates with the Google Maps API.  You have a fairly chunky 15kb Javascript file that handles your personal Google Maps integration, as well as including Google&#8217;s own API file for the maps.  Why would you want this javascript on every page of the site?  A lot of web developers and designers are guilty of putting the javascript in every single page of the site, which means that the request and corresponding bandwidth associated with the maps integration would be used even if the visitor never viewed that area of the site.</p>
<h2>Images</h2>
<p>This section is going to be quite short, as it isn&#8217;t really my department, but my main understanding is:</p>
<ul>
<li>Adobe Photoshop has a save for web feature. Use it.</li>
<li>Application specific META data is not needed in images on the web (I understand that Adobe Photoshop again can be a devil for this). Remove it if you can!</li>
<li>If you have &#8220;hover&#8221; states on buttons or navigation items, use <a href="http://www.alistapart.com/articles/sprites">CSS Sprites</a> rather than two separate images.  The reasons why are explained in the link supplied, but mainly revolve around making the hover work immediately, and reducing the number of HTTP requests.</li>
</ul>
<h2>CSS</h2>
<p>There are two situations here, really.  The majority of the time, most of the CSS will be used on all of the pages of the site, so it makes sense to make this one external cacheable file.  It is important that the CSS isn&#8217;t included in &lt;style type=&#8221;text/css&#8221;&gt;&lt;/style&gt; tags in the document itself, as this information is not cacheable and will be individually reloaded on the following page.</p>
<p>A lot of sites will include two or three CSS files. One for the site itself, and one for a plugin such as &#8220;lightbox&#8221; or &#8220;slimbox&#8221; or something similar.  If lightbox/slimbox is used on most pages, why not combine the CSS files in to one slightly larger one?  This will reduce the number of HTTP requests and put all of the CSS in to a single cached file.</p>
<p>There is an argument, also, that if there is a particularly complicated section of the web site that takes up 10kb of a CSS file all by itself, then that 10kb of the CSS should be split out in to a separate css file and included only in the complicated section, where it is needed.  This kind of optimisation will need to be assessed on a per-case basis!</p>
<p>Finally, remember that css itself can be written efficiently.</p>
<p>Compare these two blocks of code, which do the same thing, and you will see what I mean!</p>
<p><code><br />
margin-top: 10px;<br />
margin-bottom: 15px;<br />
margin-right: 5px;<br />
margin-left: 2px;<br />
</code></p>
<p><code><br />
margin: 10px 5px 15px 2px;</code></p>
<p>In conclusion, the steps above often take less than an hour to implement on a well built web site, and can save a couple of seconds per page load, and a fair amount of bandwidth costs.  With google&#8217;s <a href="http://googlewebmastercentral.blogspot.com/2010/04/using-site-speed-in-web-search-ranking.html">recent introduction of a small focus on page load time in terms of a web site&#8217;s ranking</a>, these kind of improvements have more benefits than just making the site appear faster, and are worth paying some attention!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edwardyarnold.co.uk/blog/some-simple-steps-to-reduce-web-page-download-time/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Are we there yet?</title>
		<link>http://www.edwardyarnold.co.uk/blog/are-we-there-yet</link>
		<comments>http://www.edwardyarnold.co.uk/blog/are-we-there-yet#comments</comments>
		<pubDate>Thu, 24 Jun 2010 06:31:40 +0000</pubDate>
		<dc:creator>Ed Yarnold</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.edwardyarnold.co.uk/blog/?p=120</guid>
		<description><![CDATA[I recently stumbled upon a blog post at Joel on Software about &#8216;The Iceberg Secret&#8216; &#8211; put simply, Joel explains that non technical people will judge the completeness and effectiveness of an application on the GUI alone.  You can write an amazingly complicated and involving application, put a basic unstyled page as the GUI and [...]]]></description>
			<content:encoded><![CDATA[<p>I recently stumbled upon a blog post at Joel on Software about &#8216;<a href="http://www.joelonsoftware.com/articles/fog0000000356.html">The Iceberg Secret</a>&#8216; &#8211; put simply, Joel explains that non technical people will judge the completeness and effectiveness of an application on the GUI alone.  You can write an amazingly complicated and involving application, put a basic unstyled page as the GUI and it will be assumed to be a very very early instance or to be simply terrible.  Similarly, your user interface guy can put together a beautiful  page littered with graphics &#8211; not linked to anything processing wise &#8211; and the project will be assumed to be &#8216;almost finished&#8217; or at least &#8216;not far off&#8217;.</p>
<p><span id="more-120"></span>I have worked for both technical and non technical people, and can say that it&#8217;s not only whether or not the app is finished that is judged based on the quality of the UI.  A more important factor that is judged is the productivity of the development team.  If you are a developer (which you might be if you&#8217;re reading this blog), you will know that writing models and controllers is particularly time consuming with little &#8220;real time&#8221; reward &#8211; that is,  people who aren&#8217;t programmers can&#8217;t see and don&#8217;t understand the work that you have put in.  Sometimes, this can lead to these people thinking that the programmers are doing nothing but twiddle their thumbs and get excited about charsets, or whatever it is programmers do.</p>
<p>Unfortunately I don&#8217;t think there is a lot that can be done about this, other than perhaps using these two useful analogies.</p>
<ul>
<li><strong>Writing an application is like building a house.</strong> The expensive and time consuming part is the groundwork to prepare the site, the digging of the trenches for the foundations, and the laying of those foundations.  During this time the client thinks that you&#8217;ve just made a big mess and spent lots of their money, and they haven&#8217;t got anything resembling a house to show to anybody.  Additionally, if the foundations aren&#8217;t laid correctly, the reset of the building will be more likely to fail.</li>
<li><strong>An application is like a car</strong>.  It doesn&#8217;t matter how much time the engineers spend perfecting the handling and power delivery of the vehicle.  If it doesn&#8217;t look nice, the majority of people won&#8217;t like it, and even more people would decline the opportunity to buy it.  The engineering team needs to be backed up by a telented designer to make a successful product.</li>
</ul>
<p>The judgement of quality or completeness of an application makes it difficult as a developer to put together any kind of portfolio.  You want your portfolio to *look* good &#8211; in full knowledge that people will judge the sites you have built on look and feel over functionality &#8211; despite the fact that you are not applying for a designer&#8217;s job at all.  But quite often the projects that look the prettiest are the most mundane and simple in terms of technology behind the scenes.  In addition to this, it&#8217;s rare (but not impossible) that you find an interviewer who is genuinely interested or excited by the way that you have achieved things technically, so talking through how you fully integrated your web application with Microsoft Sharepoint won&#8217;t interest them.  After all, all those months of development and there&#8217;s nothing fancy to see, only an &#8220;Update Website from Sharepoint&#8221; button in the web app&#8217;s control panel.  Really, it took 3 months to add that button?  I have a cousin in London who can do that kind of thing in an hour or two.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edwardyarnold.co.uk/blog/are-we-there-yet/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Collective Ownership of Code: Anyone should be able to fix anything that is broken!</title>
		<link>http://www.edwardyarnold.co.uk/blog/collective-ownership-of-code-anyone-should-be-able-to-fix-anything-that-is-broken</link>
		<comments>http://www.edwardyarnold.co.uk/blog/collective-ownership-of-code-anyone-should-be-able-to-fix-anything-that-is-broken#comments</comments>
		<pubDate>Fri, 07 May 2010 18:23:58 +0000</pubDate>
		<dc:creator>Ed Yarnold</dc:creator>
				<category><![CDATA[Best Practice]]></category>
		<category><![CDATA[Project Management]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.edwardyarnold.co.uk/blog/?p=115</guid>
		<description><![CDATA[In reading up on programming practices and ideals, I have stumbled across a concept called &#8220;Collective Code Ownership&#8221;.  This essentially means that *any developer* can fix bugs or write any new feature in *any project*.  Bug fixing and project development should not be limited to the person that wrote the code in the first place.   [...]]]></description>
			<content:encoded><![CDATA[<p>In reading up on programming practices and ideals, I have stumbled across a concept called &#8220;Collective Code Ownership&#8221;.  This essentially means that *any developer* can fix bugs or write any new feature in *any project*.  Bug fixing and project development should not be limited to the person that wrote the code in the first place.   This introduces both advantages and disadvantages in to project management.</p>
<p><span id="more-115"></span></p>
<h3>The Concept</h3>
<p>The concept behind this is simple.  Every developer can be responsible for the code in any project.  As mentioned above, this means that bug fixes can be made by any developer, and new features can be developed by any developer.  Here&#8217;s wikipedia&#8217;s current take on the matter:</p>
<blockquote><p>Collective code ownership means that everyone is responsible for all the  code; this, in turn, means that everybody is allowed to change any part  of the code.</p></blockquote>
<h3>The Advantages</h3>
<p>In my opinion this introduces the following advantages.</p>
<ul>
<li>If a member of your development team is immersed in an important project and needs to be allowed to &#8220;get in the zone&#8221; and work <a href="http://bigthink.com/ideas/18522">interruption free</a>, then if code they have written is deemed to be broken, any other member of the development team can fix the problem.</li>
<li>This increases exposure of application code.  The more developers that have seen code and got their head around the way it works, the better!  When the developer that wrote the code leaves, it would be helpful to have other people who have at least seen the code and knows that it exists!</li>
<li>Fresh pairs of eyes can foresee other problems with the code.  Imagine constructing a delete query using a function called constructInClause, which is passed an array.  This will return an SQL IN() clause statement.  &#8220;Hang on a minute, what if the function constructInClause returns an empty string? Won&#8217;t that delete everything from the database?&#8221; &#8211; better to spot this before rather than after the bug is exposed.</li>
</ul>
<h3>The Disadvantages</h3>
<p>With every new approach comes disadvantages alongside the advantages.  Unfortunately, I do see a couple with this one:</p>
<ul>
<li>Allowing other developers to fix bugs and modify code can mean that they will not necessarily bear in mind the full knock on effects of a change.  Dependencies on code working a certain way are commonplace &#8211; even if not ideal &#8211; in web based applications.  (Note: Unit Testing could probably avoid this situation!)</li>
<li>There is a danger of one person in the office becoming the &#8220;bug fix person&#8221;.  Not many developers enjoy fixing bugs all day, so in my view it would be important to try to make sure that responsibility for fixing bugs is shared equally between the development team.</li>
</ul>
<h3>Will I be encouraging the company I work for to encourage collective code ownership?</h3>
<p>Probably, yes!  It seems like a very sensible idea, especially considering that at times interruption to fix bugs is really quite infuriating!  If the bug fixing could be assigned to the &#8220;most interruptable&#8221; developer at any one time, I&#8217;m sure that productivity <strong>and</strong> developer mood would both be improved.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edwardyarnold.co.uk/blog/collective-ownership-of-code-anyone-should-be-able-to-fix-anything-that-is-broken/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple steps towards accurate project estimates</title>
		<link>http://www.edwardyarnold.co.uk/blog/accurate-project-estimates</link>
		<comments>http://www.edwardyarnold.co.uk/blog/accurate-project-estimates#comments</comments>
		<pubDate>Wed, 05 May 2010 17:12:50 +0000</pubDate>
		<dc:creator>Ed Yarnold</dc:creator>
				<category><![CDATA[Best Practice]]></category>
		<category><![CDATA[Project Management]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.edwardyarnold.co.uk/blog/?p=104</guid>
		<description><![CDATA[A mistake that many developers (including myself) have made in the past is to over-promise and under-deliver in terms of the absolute deadline or the number of hours taken on a project.  Getting to the &#8220;missing the deadline&#8221; or &#8220;being over budget&#8221; stage can be especially demotivating &#8211; you&#8217;re costing yourself (or your company) time, [...]]]></description>
			<content:encoded><![CDATA[<p>A mistake that many developers (including myself) have made in the past is to over-promise and under-deliver in terms of the absolute deadline or the number of hours taken on a project.  Getting to the &#8220;missing the deadline&#8221; or &#8220;being over budget&#8221; stage can be especially demotivating &#8211; you&#8217;re costing yourself (or your company) time, which is valuable, and also the client is likely to be getting slightly irritated (if you are late).  The steps or methods to reduce the chances of this happening in the first place are simple, and easy to use.<br />
<span id="more-104"></span></p>
<h3>1. Make sure you understand the problem in full.</h3>
<p>Generally, when we are presented with a problem by either a client, or a project manager, the problem has been simplified somewhat.  A 15 minute phone conversation or meeting is condensed in to a three sentence paragraph asking you the best way around a problem.  In my eyes, there are a couple of approaches to avoid this.</p>
<ol>
<li><strong>Be involved in the meeting, or the phone conversation</strong>.  This is not always possible &#8211; not every developer wants to be interrupted every 30 minutes by client questions, and not every developer is necessarily comfortable talking to a client.  But listening in on (and not participating in) a conversation could always be an option!  This means that you get to hear everything that the client has said about the problem.  It&#8217;s to be expected that the person relaying the message will miss out minor (but not necessarily insignificant) details.  After all, repeating every phone conversation in full could get a bit tiresome, you&#8217;d imagine!</li>
<li><strong>Know to ask the right questions.</strong> A client asks to make their delivery fee increase with every product added.  Let&#8217;s say, increase the delivery fee by 30% for every additional product that needs delivering.  This is simple enough, until you consider that the delivery fee could easily escalate way out of control.  A £10 standard delivery fee could soon escalate to around £50 if someone bought a large amount of products.  This could discourage a purchase.  So should a limit be introduced for the maximum delivery fee?  Remember, the client probably hasn&#8217;t thought around this issue.  Asking the question and getting an answer before work starts could save you from having to rewrite a chunk of code.</li>
</ol>
<h3>2. If dealing with unfamiliar technology&#8230; allow some research time!</h3>
<p>If you&#8217;ve been asked to implement an unfamiliar technology, take 10 or 15 minutes to research how it all works.  15 minutes spent now could stop you from estimating that something will take 5 hours when it might take 20, or from estimating 20 hours when it might take 5!   Additionally, when estimating how long the work will take, remember that you will probably spend a fair chunk of time reading documentation and not actually writing code.  In many places this would be considered billable time &#8211; and it should certainly be taken in to account when working out how soon you could deliver the work.</p>
<h3>3.  Remember to allow time for testing and bug fixing.</h3>
<p>Not everyone does this, but in my opinion it is essential.  Allow some time for proper testing and the time it&#8217;ll take to fix bugs (this can only be estimated) as well as the time taken to write the code in the first place.</p>
<h3>4. If dealing with third party services, you can&#8217;t accurately promise a deadline.</h3>
<p>A lot of the work I do involves integration with third party services &#8211; payment gateway services, SMS services, etc.  These all involve an account application and signup process, and sometimes this process depends on the client completing a form, or submitting payment for the service.   I have found that it is almost impossible to accurately estimate a &#8220;go live&#8221; date when an aspect of your application depends on a third party service being ready for use.  If you do provide an estimated go live date, it could be worth putting in a note that it depends on the client&#8217;s service X application being complete by date Y.</p>
<h3>5. If you feel out of your depth, don&#8217;t be afraid to say!</h3>
<p>This is a very important point.  If you are not confident about working with and fully understanding the technology that you will be using, <strong>tell your manager or your client! </strong>It&#8217;s better to say at this stage than to blindly assume that you will be able to work something out during the work.  They will be a darn sight happier this way around than if you go out of your depth and then the project is late or massively over budget.  Saying now typically will have one of three results:</p>
<ol>
<li><strong>Your company will turn the work away</strong> to avoid a problem (or, your client will go elsewhere).</li>
<li><strong>Measures will be put in place to avoid the issue.</strong> Billing by the hour, or using another developer, for instance.</li>
<li><strong>The project will be quoted anyway at an estimated rate, and your company will take a risk.</strong> In this case, you at least said something at the start &#8211; the risk taken was by someone above you.</li>
</ol>
<p>These are only very basic steps that can be taken to avoid a problem.  But one thing is for certain.  It is typically better to <strong>under promise and over deliver</strong> rather than the other way around.  You just have to be careful that you don&#8217;t fall in to the habit of *massively* over-quoting projects, because this can have a detrimental effect in terms of reducing the percentage of accepted quotations.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edwardyarnold.co.uk/blog/accurate-project-estimates/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Should you sanitise your HTML before or after you save to your database?</title>
		<link>http://www.edwardyarnold.co.uk/blog/when-to-sanitise-data</link>
		<comments>http://www.edwardyarnold.co.uk/blog/when-to-sanitise-data#comments</comments>
		<pubDate>Mon, 19 Apr 2010 12:52:58 +0000</pubDate>
		<dc:creator>Ed Yarnold</dc:creator>
				<category><![CDATA[Best Practice]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.edwardyarnold.co.uk/blog/?p=85</guid>
		<description><![CDATA[In starting a new project completely from scratch we need to decide whether to sanitise html (that is, convert &#38; to &#38;amp;, &#60; to &#38;lt;, and strip out blacklisted html) before or after we saved to database.  In projects I&#8217;d worked on in the past this had been done inconsistently in different areas of the [...]]]></description>
			<content:encoded><![CDATA[<p>In starting a new project completely from scratch we need to decide whether to sanitise html (that is, convert &amp; to <code>&amp;amp;</code>, &lt; to <code>&amp;lt;</code>, and strip out blacklisted html) before or after we saved to database.  In projects I&#8217;d worked on in the past this had been done inconsistently in different areas of the application &#8211; ie, pre save in some areas and on select in others.  After having thought through the problem I think I&#8217;ve decided on which option I prefer: Sanitise after selecting from the database, rather than before saving to the database.</p>
<p><span id="more-85"></span>My reasons for this decision are as follows:</p>
<ol>
<li><strong>Database collation</strong>.  Searching for strings <code>LIKE '%Ed, Ed &amp; Eddie%'</code> starts to get complicated if you have converted &amp; to &amp;amp; &#8211; you have to remember to convert entities in your search string as well.  This could also potentially mess up the effect ORDER BY clauses in the SQL queries you write have on the dataset.</li>
<li><strong>Data Integrity</strong>.  If in the future I decide that I all HTML, or just specific previously blacklisted HTML tags to be allowed, the data is all still complete and certain aspects of the data have not been removed.</li>
<li><strong>Application Consistency</strong>.  I know that if I am ever displaying data selected from the database it will need to be &#8216;sanitised&#8217; before being displayed to the user either in repopulated &#8216;edit&#8217; forms or in a normal &#8216;view&#8217; type screen.</li>
</ol>
<p>I also did a little bit of research in the cakephp manual (as we will be using cakephp for this next project) to see what cakephp creators thought about this and it seems they reached the same conclusion (quoted from <a href="http://book.cakephp.org/view/153/Data-Sanitization">this page</a>):</p>
<blockquote><p>For sanitization against XSS its generally better to save raw HTML in  database without modification and sanitize at the time of  output/display.</p></blockquote>
<p>They don&#8217;t give any specific reasons but I imagine that their thought process was similar to mine.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edwardyarnold.co.uk/blog/when-to-sanitise-data/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How I organise my project information to save time.</title>
		<link>http://www.edwardyarnold.co.uk/blog/organisation-time-saving</link>
		<comments>http://www.edwardyarnold.co.uk/blog/organisation-time-saving#comments</comments>
		<pubDate>Mon, 12 Apr 2010 06:16:19 +0000</pubDate>
		<dc:creator>Ed Yarnold</dc:creator>
				<category><![CDATA[Best Practice]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.edwardyarnold.co.uk/blog/?p=51</guid>
		<description><![CDATA[It shouldn&#8217;t be news to anyone, but organising your projects (and assets within those projects) in an efficient manner will save you a load of time.   Perhaps not immediately, but at some point in the future you&#8217;ll be thanking yourself hundreds of times over that you took the time to organise things in the first [...]]]></description>
			<content:encoded><![CDATA[<p>It shouldn&#8217;t be news to anyone, but organising your projects (and assets within those projects) in an efficient manner will save you a load of time.   Perhaps not immediately, but at some point in the future you&#8217;ll be thanking yourself hundreds of times over that you took the time to organise things in the first place.</p>
<p><span id="more-51"></span>Starting with the basics, organisation in projects can be as simple as ensuring that you store all information supplied by the client with the project, in a folder called something like &#8216;assets&#8217;.   Typically I would split them by asset type &#8211; images for web, images for print, documents for web download, internal documents, other &#8211; and perhaps include a &#8216;supply date&#8217; in the filename of each.</p>
<p>Next, write stuff down!  If a particular part of the project depends on an external service being available, write this down in a document that stays with the project wherever it goes.  Any useful information that is in your head the day you write the code for the project should probably be written down.  You more than likely won&#8217;t remember in 2 years time when something goes wrong!  All of this information could simply be stored in a README file.</p>
<p>Good organisation doesn&#8217;t boil down to simply putting things in to folders, or keeping notes.  Of course, these actions are a part of the organisation, but don&#8217;t cover everything.  More importantly &#8211; especially in the IT industry &#8211; consistency can be the best time saving characteristic you can introduce to your work.  Being consistent is almost synonymous with being organised when it comes to your project management&#8230;</p>
<p>I save time (and frustration!) by:</p>
<ul>
<li>Naming projects consistently.  My project name tends to match the main part of the domain name on which the web site or project will be hosted.  If I&#8217;ve a domain called edwardyarnold.co.uk, the project in my subversion repository will be called edwardyarnold.  This makes it a lot quicker to put my hand on the correct project if a change needs to be made.</li>
<li>Naming the associated MySQL databases consistently.  For the above project, the CMS database would be called edwardyarnold_cms.  If the site were an ecommerce site, it would be called edwardyarnold_ecom.  This makes finding the relevant database in a phpmyadmin screen much quicker than if the databases weren&#8217;t named consistently.</li>
<li>Ensuring that if a project is replaced with an entirely new version, it is archived with a date.  If I replaced the edwardyarnold.co.uk site with a completely new build, I&#8217;d move the current project to edwardyarnold_2010_archive and create a new one to replace the old.  This is a better approach to dating the new version of the site &#8211; the new version of the site would still exist in 2011 but would appear to be out of date if dated 2010.  Annoying to anyone who didn&#8217;t know that that was the &#8216;latest&#8217; version of the site.</li>
<li>Naming administration area directories according to a set naming pattern (I won&#8217;t disclose that here).  This means that anyone who I work with that knows the pattern can find the administration area without looking up the directory name.  (They will of course have to look up the username and password, if not saved in their browser).</li>
</ul>
<p>These save a tiny amount of time individually, but collectively &#8211; and applied over multiple projects &#8211; the tiny amounts of time soon add up, and you can start to actually notice the saving.  Additionally, following these &#8216;rules&#8217; means that new people joining your team can begin to understand and get a grip of the way you work quicker than if everything was done differently for each project.  In larger organisations this can reduce recruitment costs (remember, downtime whilst training your new staff member is a hidden recruitment cost&#8230;!) as well as saving your existing team time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edwardyarnold.co.uk/blog/organisation-time-saving/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Developers (and Web Design companies): Consider using someone else to check your work!</title>
		<link>http://www.edwardyarnold.co.uk/blog/php-developers-and-web-design-companies-consider-using-someone-else-to-check-your-work</link>
		<comments>http://www.edwardyarnold.co.uk/blog/php-developers-and-web-design-companies-consider-using-someone-else-to-check-your-work#comments</comments>
		<pubDate>Mon, 22 Mar 2010 22:00:42 +0000</pubDate>
		<dc:creator>Ed Yarnold</dc:creator>
				<category><![CDATA[Best Practice]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.edwardyarnold.co.uk/blog/?p=31</guid>
		<description><![CDATA[We&#8217;ve all been there.  Working flat out on a project for day after day, to finally see the light at the end of the tunnel and start to consider launching.  But wait!  This is a dangerous situation to be in.  Having looked at the same site for so long, you&#8217;re not going to be able [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve all been there.  Working flat out on a project for day after day, to finally see the light at the end of the tunnel and start to consider launching.  But wait!  This is a dangerous situation to be in.  Having looked at the same site for so long, you&#8217;re not going to be able to spot the mistakes that you&#8217;ve made.  It&#8217;s worth spending an extra couple of hours to double-check your work &#8211; rather than have the embarassing situation of launching a site with mistakes present.</p>
<p><span id="more-31"></span>Until I worked for a couple of established Web Development companies, I never realised the importance of a &#8216;Checklist&#8217; at the end of a project.  You know, simple things.  Does the site&#8217;s markup validate?  Do all images have alt tags?  Is php display_errors off?  But even after getting in the habit of ticking all of the items off this checklist for every site I build, there are still little mistakes that creep through &#8211; miscapitalised letters, incorrectly pluralised nouns&#8230; eg &#8220;There are 1 comments on this post&#8221; should be &#8220;There is 1 comment on this post&#8221;.   No checklist can possibly cover all of these possible errors (though the one I link to later in this post gives it a good go!).</p>
<p>The best way of discovering these problems is to ask a favour of (or even to employ) someone you know &#8211; preferably without a technical background &#8211; to go through the site and see if they can spot anything that needs changing or fixing.  You will find that they will probably produce a list twice as long as your original checklist!</p>
<p>The beauty of this approach is &#8211; as well as spotting spelling mistakes and other simple errors &#8211; you may also get some <strong>vital</strong> usability feedback, especially if you are with them when they are checking the site.  Do they seem frustrated? Did they use the site in the manner you would expect them to?</p>
<p>I was once fortunate enough to be behind a one-way mirror in a usability testing session and it was simply amazing.  We had a captcha image on a form (I know, I know.. don&#8217;t start) and the error message was misunderstood or found to be confusing by nearly every user.  The abandonment (and frustration) rate on the contact form <a href="http://www.webmasterworld.com/new_web_development/3463891.htm">was therefore extremely high</a>.  This kind of problem would not normally be picked up in smaller projects where a usability testing session is not included (and you wrote the error message &#8211; so find it simple, right?), but if you run through the site with someone to whom the site is fresh, there&#8217;s a much higher chance that you will pick up the problem.  Remember that this issue wouldn&#8217;t be picked up by a checklist either!</p>
<p>So.. checking through a site with somebody non-technical (and who has never seen the site before) can save you a whole bunch of headaches in the future.  And remember &#8211; if you&#8217;re launching your web sites without a <a href="http://www.boxuk.com/blog/the-ultimate-website-launch-checklist">flight check list (check this one out from Box UK)</a>, that&#8217;s probably one of the first things you should consider implementing in your project schedule.  It will save you a lot more support time than it costs you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edwardyarnold.co.uk/blog/php-developers-and-web-design-companies-consider-using-someone-else-to-check-your-work/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The obligatory development tools post</title>
		<link>http://www.edwardyarnold.co.uk/blog/the-obligatory-development-tools-post</link>
		<comments>http://www.edwardyarnold.co.uk/blog/the-obligatory-development-tools-post#comments</comments>
		<pubDate>Mon, 22 Mar 2010 18:19:26 +0000</pubDate>
		<dc:creator>Ed Yarnold</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://local.twixcoding.com/sandbox/PERSONAL/edwardyarnold.co.uk/blog/?p=25</guid>
		<description><![CDATA[I&#8217;ve seen pretty much every other web developer with a blog do this, so why not jump on the bandwagon and do it too?  This is a list of the tools I favour when doing my job &#8211; including my web-browser of choice,  my favoured text editor and preferred FTP client. Hardware (Performance) Despite what [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve seen pretty much every other web developer with a blog do this, so why not jump on the bandwagon and do it too?  This is a list of the tools I favour when doing my job &#8211; including my web-browser of choice,  my favoured text editor and preferred FTP client.</p>
<p><span id="more-25"></span></p>
<h3>Hardware (Performance)</h3>
<p>Despite what some might tell you, web developers can not realistically get by on an old machine with Windows XP and 500kb of RAM.  We would actually like to get our work done &#8220;some time today&#8221;!  But, at the same time, we don&#8217;t need a kick-ass machine with 1gb of available Graphics Memory and 4gb of RAM.  The main things I like from a web development machine are quick application start up times and stability, both of which can be achieved with any modern operating system (I favour Windows 7 &#8211; sorry Apple fans) and a decent helping  (2gb?) of RAM.</p>
<h3>Displays</h3>
<p>I think that dual monitors are essential, and given the choice would never work on one monitor again.   I think that purchasing a second screen is a great investment.  Being able to have code on one screen and the application on the other (or email with instructions on one, code on the other.. the list is endless) speeds my work up so much more than I have ever been able to prove to anyone that has asked me to.  Try it &#8211; if you can &#8211; I don&#8217;t think you&#8217;ll ever go back to single monitor hell.</p>
<h3>Web Browser</h3>
<p>Despite it&#8217;s occasional large memory footprint, I don&#8217;t think you can beat <a href="http://www.mozilla-europe.org/en/firefox/">Firefox</a> if you&#8217;re a web developer &#8211; even if only for the incredibly useful web development add ons that are available.  I only really use two, though:</p>
<ol>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/60">The Web Developer Toolbar</a> &#8211; this has saved me more time than I could ever imagine finding why an image is fuzzy (damn CSS sizing) or why certain areas of the page appear the way they do.  It is just a huge time saver, one that in my opinion should be the first thing you install after Firefox itself.</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/1843">Firebug</a> &#8211; I find this most useful if involving myself with AJAX, it&#8217;s &#8220;net panel&#8221; is simply awesome.  I don&#8217;t even touch on half of this add on&#8217;s features, and still think it&#8217;s amazing!</li>
</ol>
<h3>Text Editor</h3>
<p>I really, really like <a href="http://www.activestate.com/komodo_edit/">Activestate Komodo Edit</a>, although I must admit that I haven&#8217;t tried anything else for at least 3 years now.  My favourite feature in this application is &#8220;Go To Definition&#8221;.  Right click a variable name, function name, or class name, click &#8220;Go To Definition&#8221; and you will be taken to either the variable assignment, function or class definition.  This has saved me loads of time!  The PHP syntax checking works well, and variable/function autocompletion is another big time saver.</p>
<h3>FTP Client</h3>
<p>When they made it paid-for a few years ago, I tried a few free-to-use alternatives and ended up back where I started, but with a fee to pay.  And in my view that fee is worth every penny.  I don&#8217;t think this FTP client can be beaten for ease of use or reliability -  <a href="http://www.smartftp.com/">SmartFTP</a>.</p>
<h3>Email Client</h3>
<p>This will come as quite a shock to most people, but I tried using Thunderbird for a period of a year and got sick to death of it&#8217;s constant memory hogging.  Now, I use Microsoft Outlook 2007 for accessing my IMAP mail at work.  But, my favoured email client of them all is <a href="http://mail.google.com">Google Mail</a>.  I love how powerful and fast the search is, and fell in love with Labels as soon as they were introduced to me.  *All* of my personal email (And freelance email) goes through it.  If they made it paid-for, I&#8217;d pay for it immediately (within reason).</p>
<h3>Scheduling Tool (Meetings, etc)</h3>
<p>I started using <a href="http://www.google.com/calendar">Google Calendar</a> in 2006, and haven&#8217;t looked back since.  The ability to share calendars to view, or view &amp; edit, and the ease of synchronisation between this service and a whole load of mobile phones makes this an immediate recommendation for me.  Not forgetting of course that I can log in to google.com/calendar anywhere in the world and view or edit my schedule!  This is my favourite web-based app to date, and my favourite use of AJAX.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edwardyarnold.co.uk/blog/the-obligatory-development-tools-post/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Save your script some time: Remember to index those foreign keys!</title>
		<link>http://www.edwardyarnold.co.uk/blog/save-your-script-some-time-remember-to-index-those-foreign-keys</link>
		<comments>http://www.edwardyarnold.co.uk/blog/save-your-script-some-time-remember-to-index-those-foreign-keys#comments</comments>
		<pubDate>Mon, 22 Mar 2010 17:53:27 +0000</pubDate>
		<dc:creator>Ed Yarnold</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://local.twixcoding.com/sandbox/PERSONAL/edwardyarnold.co.uk/blog/?p=16</guid>
		<description><![CDATA[In my infancy as a web developer, I was often caught out by a lot of really simple problems.  One of these really simple problems was slow SELECT queries on a MySQL database when using &#8220;JOIN&#8221; or &#8220;WHERE&#8221;.  I was quite often baffled; the site seemed really quick when I first launched it, and I [...]]]></description>
			<content:encoded><![CDATA[<p>In my infancy as a web developer, I was often caught out by a lot of really simple problems.  One of these really simple problems was slow SELECT queries on a MySQL database when using &#8220;JOIN&#8221; or &#8220;WHERE&#8221;.  I was quite often baffled; the site seemed really quick when I first launched it, and I hadn&#8217;t made any code changes, so what could have changed that made the &#8220;News Listing&#8221; page so slow?  The answer was staring me in the face, but it still took me a bit of time to find it.  The problem?  The database table had a higher number of records in it, and when JOINING or searching, the application was forcing MySQL to do what are called &#8220;full table scans&#8221;.   Once I discovered this was the problem, I was amazed at the difference in performance something so simple could result in.<span id="more-16"></span></p>
<p>Before I go any further, I  want to explain (or rather, quote someone else explaining) what indexing does.   A really useful source of information for me when I was investing this issue, was entitled “<a href="http://oreilly.com/catalog/9780596001452">MySQL Cookbook</a>”  &#8211; an 8 year old but incredibly useful book  that I have successfully counted on each time I have hit a brick wall with MySQL.</p>
<blockquote><p>Typically, indexing a column that you query frequently helps SELECT  statements run faster because the index allows MySQL to avoid full table  scans. If you update this row more frequently than you SELECT or JOIN  on it, you may be better off not indexing, as every time an UPDATE or  INSERT query is ran, mysql must update the indexes for those columns.</p></blockquote>
<blockquote><p>Because  a join can easily cause MySQL to process large numbers of row  combinations, it’s a good idea to make sure that the columns you’re  comparing are indexed. Otherwise, performance can drop off quickly as  table sizes increase.</p></blockquote>
<p><strong>Example</strong></p>
<p>You have a “product” and “product_image” table. The  primary key in “product” is product_id. You have a column in  “product_image” called “product_id”, which “links” the product image to  the product that it belongs to.  <strong> product_id in both tables should be  indexed</strong>!!</p>
<p>To give an example of the kind of speed increase this results in…</p>
<p>An application with this exact issue had a query which was taking on average, 8 to 10 seconds. After adding  the index to the second table, that same query took only 0.02 seconds.  This is a quite frankly amazing difference, and all achieved just by indexing a single column.</p>
<p>Conclusion: As a general rule of thumb, any column in a database  called (something)_id should be &#8220;indexed&#8221;. Exceptions will probably exist (in frequent-update and insert situations, for example), but if &#8211; as is often the case with web-apps &#8211; you SELECT more often than you UPDATE or INSERT, it&#8217;s a pretty concrete rule that you can stick to.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edwardyarnold.co.uk/blog/save-your-script-some-time-remember-to-index-those-foreign-keys/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
