<?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>Fri, 06 Apr 2012 11:09:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Ubuntu Server within VirtualBox on Windows 7</title>
		<link>http://www.edwardyarnold.co.uk/blog/ubuntu-server-within-virtualbox-on-windows-7</link>
		<comments>http://www.edwardyarnold.co.uk/blog/ubuntu-server-within-virtualbox-on-windows-7#comments</comments>
		<pubDate>Fri, 06 Apr 2012 10:59:42 +0000</pubDate>
		<dc:creator>Ed Yarnold</dc:creator>
				<category><![CDATA[Me]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[VirtualBox]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.edwardyarnold.co.uk/blog/?p=236</guid>
		<description><![CDATA[In the past I have used an old Dell PC for my development server, generally installing a server distribution of Linux (first CentOS, recently Ubuntu &#8211; I made the move primarily because of the great documentation available for Ubuntu, and for the fact that is used by more people). Just recently, the HDD in my [...]]]></description>
			<content:encoded><![CDATA[<p>In the past I have used an old Dell PC for my development server, generally installing a server distribution of Linux (first CentOS, recently Ubuntu &#8211; I made the move primarily because of the great documentation available for Ubuntu, and for the fact that is used by more people).</p>
<p>Just recently, the HDD in my development server has started to become noisy and so I took the decision this morning to replace my development setup before it was forced upon me at an even more inconvenient moment.  I decided that I am not a big fan of using the electricity it takes to power two individual machines, plus it takes up quite a lot of space in my home office.  For this reason I decided to investigate virtualisation and whether or not I can run Ubuntu &#8216;within&#8217; Windows 7 (my &#8216;host&#8217; OS).  Whilst not comprehensive, this set of instructions will hopefully help someone out a bit if they&#8217;re ever looking to do something similar to this&#8230;.</p>
<p><span id="more-236"></span></p>
<p>My main requirements (beyond all the usual ones for a development web server) were defined as follows:</p>
<ol>
<li>I must be able to access the filesystem of the development machine through a fileshare of some kind (in the past I have used Samba) both on the host machine <em>and on other machines on my LAN</em>.</li>
<li>The websites I am developing must also be accessible by other machines on the LAN (by navigating to an IP address).</li>
</ol>
<p>I ended up stumbling upon <a href="https://www.virtualbox.org/">Oracle VM VirtualBox</a> which seemed to enable me to do exactly what I wanted.</p>
<p>The steps I took were as follows:</p>
<ol>
<li>Download and install <a href="https://www.virtualbox.org/wiki/Downloads">Oracle VM VirtualBox</a> &#8211; as I am a Windows 7 user I installed the Windows version.</li>
<li>I set up a virtual machine, following the <a href="https://www.virtualbox.org/manual/ch01.html#gui-createvm">excellent instructions provided by VirtualBox</a></li>
<li>I downloaded a disc image (.iso) of <a href="http://www.ubuntu.com/download/server/download">Ubuntu Server Edition 11.10</a></li>
<li>I then added the downloaded Ubuntu disk image (the .iso) to the storage devices so that I could boot with it on my virtual machine. For the virtual machine in question, I clicked on <strong>Settings</strong><strong> then Storage</strong>. Under <em>CD/DVD Device</em>, next to <em>Empty</em>, I clicked the little folder icon and selected the Ubuntu .iso I had downloaded earlier.   This means that the virtual machine will start up, treating the .iso image as a genuine, burnt CD in a CD drive, and installation can be done from there.</li>
<li>I started the Virtual Machine and installed Ubuntu Server Edition &#8211; excellent instructions for setting up Ubuntu 11.10 as a dev. server are available all over the internet and are updated all the time, so consult google!  Generally from this point on, installation is as-per-any-other install&#8230;</li>
<li>Importantly, in order to satisfy my two requirements, I had to make a setting change for how the network behaves for this virtual machine: I changed it from NAT mode to &#8216;Bridge&#8217; mode.  Right click the virtual server in VirtualBox, click &#8220;Settings&#8221;, then go to the &#8220;Network&#8221; tab and select &#8220;Bridged Adapter&#8221; in the &#8220;attached to:&#8221; drop down menu for Adapter 1.  I then configured the ubuntu network interfaces to use a fixed IP address in the same IP address range as the host machine (192.168.0.10 in my case) and was then able to access http://192.168.0.10 on all devices connected to my LAN.</li>
</ol>
<p>Other useful links:</p>
<ul>
<li><a href="https://help.ubuntu.com/11.10/serverguide/C/index.html">Ubuntu Documentation</a> &#8211; for 11.10 server edition</li>
<li><a href="https://help.ubuntu.com/11.10/serverguide/C/network-configuration.html#ethernet-interfaces">Ethernet Device Configuration &#8211; for Ubuntu</a> &#8211; helpful for setting up a static IP address</li>
<li><a href="https://help.ubuntu.com/11.10/serverguide/C/samba-fileserver.html">Samba Fileshare documentation</a></li>
</ul>
<h3>Useful points (These generally revolve around little annoyances with the &#8220;out of the box&#8221; LAMP server that comes with Ubuntu 11.10 with a quick path to resolution).</h3>
<ol>
<li>mod_rewrite is not enabled by default. To enable, type &#8220;sudo a2enmod rewrite&#8221; on the command line, modify /etc/apache2/apache2.conf and change AllowOverride None to AllowOverride All in the /var/www/ directory section.  Then restart apache.  mod_rewrite will now be available.</li>
<li>curl is not installed by default.  To install, type &#8220;sudo apt-get install curl&#8221; and install, then &#8220;sudo apt-get install php5-curl&#8221; and install, then restart apache.</li>
<li>Some of the php.ini settings are ridiculous &#8211; this will be down to your own preferences, but my advice would be to do a phpinfo(); page and inspect every configuration option!</li>
<li>Virtual hosts can be set up by creating vhost.conf files in /etc/apache2/sites-available and then symlinking them in /etc/apache2/sites-enabled &#8211; remember to restart apache every time you add a vhost.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.edwardyarnold.co.uk/blog/ubuntu-server-within-virtualbox-on-windows-7/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP: Detect if any Chinese characters are in a unicode string</title>
		<link>http://www.edwardyarnold.co.uk/blog/php-detect-if-any-chinese-characters-are-in-a-unicode-string</link>
		<comments>http://www.edwardyarnold.co.uk/blog/php-detect-if-any-chinese-characters-are-in-a-unicode-string#comments</comments>
		<pubDate>Fri, 09 Mar 2012 11:51:29 +0000</pubDate>
		<dc:creator>Ed Yarnold</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Regex]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[UTF-8]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.edwardyarnold.co.uk/blog/?p=233</guid>
		<description><![CDATA[We were looking for a way to detect if any chinese characters existed in a Unicode string in PHP, and came up with the following, which uses Unicode Scripts: preg_match('/\\p{Han}/u', $description, $matches); if(count($matches) &#62; 0) { // chinese characters exist in $description. }]]></description>
			<content:encoded><![CDATA[<p>We were looking for a way to detect if any chinese characters existed in a Unicode string in PHP, and came up with the following, which uses <a href="http://www.regular-expressions.info/unicode.html" target="_blank">Unicode Scripts</a>:</p>
<pre>preg_match('/\\p{Han}/u', $description, $matches);
if(count($matches) &gt; 0) {
// chinese characters exist in $description.
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.edwardyarnold.co.uk/blog/php-detect-if-any-chinese-characters-are-in-a-unicode-string/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Aims for the following year</title>
		<link>http://www.edwardyarnold.co.uk/blog/aims-following-year</link>
		<comments>http://www.edwardyarnold.co.uk/blog/aims-following-year#comments</comments>
		<pubDate>Sun, 04 Mar 2012 11:22:13 +0000</pubDate>
		<dc:creator>Ed Yarnold</dc:creator>
				<category><![CDATA[Me]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.edwardyarnold.co.uk/blog/?p=162</guid>
		<description><![CDATA[The last twelve months have been busy for me &#8211; I got married, we bought our first house together in Cardiff and I started working remotely.  With things having settled down slightly, I have had some time to consider what I&#8217;d like to achieve this following year when it comes to my own development.  My [...]]]></description>
			<content:encoded><![CDATA[<p>The last twelve months have been busy for me &#8211; I got married, we bought our first house together in Cardiff and I <a href="http://www.edwardyarnold.co.uk/blog/working-from-home-month-1">started working remotely</a>.  With things having settled down slightly, I have had some time to consider what I&#8217;d like to achieve this following year when it comes to my own development.  My aims range from Unit Testing my code and developing in a Test Driven manner to speaking to industry peers at a developer meet.  I&#8217;ve listed my aims in this post.</p>
<p><span id="more-162"></span></p>
<h3>Unit Test my existing code</h3>
<p>Unit Testing verifies that individual units of source code do what they were intended to do.  Quite simply, I would like to spend the time writing and running unit tests for existing code in our business &#8211; I am due to refactor a substantial part of our ecommerce software in terms of basket total calculations and discount implementations and feel that these are perfect areas to implement unit testing before the refactoring begins.   This way, the software can be verified to be working the way it should be today, and then verified to still be working the way it should be after the code has been refactored.</p>
<h3>Practice Test Driven Development</h3>
<p>My basic understanding of Test Driven Development is essentially the idea that you write test cases that define what you would like your function/method to achieve, and then write (preferably the minimum amount of) code to allow those test cases to pass.  It is very much a &#8216;test first&#8217; principle &#8211; writing tests first and developing this way has many advantages:</p>
<ul>
<li>Coming up with the tests in the first place often requires investigative thinking in to the problem, which allows the developer to better understand the problem that needs to be solved.</li>
<li>Requirements are therefore established firmly before code is written.</li>
<li>It can be immediately determined whether the functionality is complete (when all tests pass, the code has fulfilled the specification)</li>
<li>The tests have already been written, so if the code  is refactored at a point in the future, the process of testing that refactored code is short and simple.</li>
<li>As tests tend to be concise and binary by nature, the code written to pass each test tends to also be concise and each method/function tends to have a single purpose.  This naturally reduces the chances of the occurence of <a href="http://en.wikipedia.org/wiki/Spaghetti_code" target="_blank">spaghetti code</a> and follows the programming rule that &#8216;everything should do only one thing&#8217;.</li>
</ul>
<p>I&#8217;ve yet to actually develop this way, and over the following few months it is my aim to do so.</p>
<h3>Attend a Conference/Developer Meets</h3>
<p>This one is a bit of an easy aim, really.  I read a lot about conferences and developer meetups &#8211; mainly through Twitter  - but feel that actually being in the room where these people talk about the industry would be a better experience.  I&#8217;ve booked a ticket to attend the <a href="http://port80events.co.uk/" target="_blank">port80 mini web conference</a> in Newport, South Wales and hope to rub shoulders with those in the industry with experience and advice that they are willing to share.  In addition to this I have pledged to attend at least some of the <a href="http://unifieddiff.co.uk/" target="_blank">UnifiedDiff</a> meets in Cardiff (UnifiedDiff is a monthly meet-up for anyone interested in software development) with a view to learning things from people with much more experience and knowledge than myself.</p>
<h3>Put together a presentation about something in the industry</h3>
<p>The UnifiedDiff meet tends to feature 3 talks covering any aspect of Software Development.   This has shown to me that people out there have real passion for what they do every day, and even more importantly, that people are prepared to hear about it! With my experience of working remotely for a small-medium sized Web Development firm, I think I&#8217;m going to start to write a presentation about the pros and cons of working as a remote developer, and how developers and project managers alike can work to make the process easier if this is something they wish to explore.  If I end up being confident enough that the presentation is of high enough quality, I might even ask if I can feature as a speaker at one of the UnifiedDiff meets.</p>
<h3>Understand Git &#8211; and then start using it.</h3>
<p>I am still a big Subversion fan and am yet to be convinced of the advantages of Git (in terms of justifying the time expense of a move from one to the other).  The problem is &#8211; every intelligent chap that I know and respect in this industry seems to sing the praises of Git on a near daily basis, and nearly everyone I speak to is looking to make a move to it.  So I need to research and understand what advantages Git offers over subversion, actually use it for a personal project or two so that I understand it, and reassess my feelings on it.</p>
<p>Hopefully, I will make the time to blog about and share my experiences on each of the above points &#8211; check back here over the coming 12 months to see how I&#8217;m getting on!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edwardyarnold.co.uk/blog/aims-following-year/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Discouraging the accumulation of Technical Debt</title>
		<link>http://www.edwardyarnold.co.uk/blog/discouraging-the-accumulation-of-technical-debt</link>
		<comments>http://www.edwardyarnold.co.uk/blog/discouraging-the-accumulation-of-technical-debt#comments</comments>
		<pubDate>Mon, 12 Dec 2011 18:12:23 +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=215</guid>
		<description><![CDATA[I&#8217;m nearly four years on from starting with my current employer. This is quite an interesting phase of my employment, in that sites that I worked on when I first started are all reaching the stage where they&#8217;re being refreshed, upgraded or completely rewritten.  What this seems to be doing is highlighting to me that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m nearly four years on from starting with my current employer. This is quite an interesting phase of my employment, in that sites that I worked on when I first started are all reaching the stage where they&#8217;re being refreshed, upgraded or completely rewritten.  What this seems to be doing is highlighting to me that there really is such a thing as <a href="http://en.wikipedia.org/wiki/Technical_debt">Technical Debt</a> and it really can be as evil as people say it can.</p>
<p><span id="more-215"></span>As developers, we are often rewarded with praise (or more) for turning new features around quickly.  If your company estimates that a particular feature will take eight hours to write, and you take only four, the company&#8217;s making a tidy profit, you can move to the next item in your schedule more quickly and everyone is happy.  This is all very well, so long as that feature has been written properly and in accordance with your company&#8217;s general approach; everything ranging from naming conventions right through to the organisation of the filesystem.  If it hasn&#8217;t been written properly, then you have incurred technical debt, and at a point in the future either you or another developer maintaining your code may need to spend more time writing a feature or changing your feature than anticipated.</p>
<p>This can cause all manner of problems.  When you come to develop on from your last feature, you might estimate that another bit of functionality will take 8 hours to write.  However, when trying to hook in to the existing feature, you discover your technical debt, and end up having to refactor the existing code to allow you to do what you wish.  This might take another 4 hours.  This might not seem to be a disaster; after all, you were 4 hours up on the first feature, and we&#8217;re just back where we should be now, right? Wrong! It is important to remember that managing our time isn&#8217;t  just about managing the absolute amount of time taken, but keeping to schedules.  The 4 hours it takes to sort out the mess in this second round of development delays the next item in your project schedule, which might result in a disappointed client.</p>
<p>In my opinion it would have been better to take the full scheduled 8 hours in the first round of development and avoid the unexpected hold-up during the second round of development.  The 4 hours in the first instance are less expensive than the 4 hours in the second, as they&#8217;ve less of an effect on surrounding projects &amp; priorities.</p>
<p>The trouble is, at the time the new feature is written, it can be difficult for someone non-technical to tell the difference between it having been done quickly and it having been done properly.  In fact, from an end-user&#8217;s point of view, the system can look absolutely identical.   So, given two developers, one who can turn the feature around in 4 hours, and another who takes twice as long at 8 hours, which will the project manager or client be more happy with? My money would nearly always be on the 4 hour guy. But long term, the 8 hour guy is actually going to be less expensive to run, or will at least facilitate more accurate estimates and quotes on the same system in the future.  The problem is, as developers, we need to resist the temptation to be the 4 hour guy. The short term praise can be addictive and it&#8217;s understandable why it seems easier and more tempting to do things as quickly as possible and worry about the consequences later.</p>
<p>What I&#8217;m noticing is, in 2008 I WAS the 4 hour guy. I was turning around features faster than other people had in the past, and grew a reputation for being quicker.  While I was quicker at the time, now, 4 years on, when I&#8217;m revisiting those sites and starting to improve or extend them, I&#8217;m paying off my technical debt with &#8216;expensive&#8217; rewriting and refactoring.  So now I&#8217;m in the position where I am expecting the implementation of a change request to take a given amount of time, but on loading up the project and seeing the way it was written in the first place, the implementation is taking much longer.  This extra development time is difficult to explain and to justify to those responsible for project scheduling, and is something that I&#8217;m going to really strive to avoid in the future, even if it does seem to take me slightly longer to develop new features than before.</p>
<p>It seems sensible to finish this post with one of the more famous quotes about computer programming. I&#8217;m sure you&#8217;ll have <a href="http://c2.com/cgi/wiki?CodeForTheMaintainer">read it before</a>&#8230;</p>
<blockquote><p>Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live</p></blockquote>
<p>Trust me, it&#8217;s bad enough even if it&#8217;s YOU that ends up maintaining your code!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edwardyarnold.co.uk/blog/discouraging-the-accumulation-of-technical-debt/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working from home: Month 1</title>
		<link>http://www.edwardyarnold.co.uk/blog/working-from-home-month-1</link>
		<comments>http://www.edwardyarnold.co.uk/blog/working-from-home-month-1#comments</comments>
		<pubDate>Wed, 31 Aug 2011 07:09:01 +0000</pubDate>
		<dc:creator>Ed Yarnold</dc:creator>
				<category><![CDATA[Me]]></category>
		<category><![CDATA[Remote Working]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.edwardyarnold.co.uk/blog/?p=199</guid>
		<description><![CDATA[I have just completed my first full calendar month of the new teleworking arrangement I have with my current employer, so feel it is a good time to write down some of my feelings and detail my experience thus far.  My arrangement is to work remotely for 3 days of my 5 day week, travelling [...]]]></description>
			<content:encoded><![CDATA[<p>I have just completed my first full calendar month of the new teleworking arrangement I have with my current employer, so feel it is a good time to write down some of my feelings and detail my experience thus far.  My arrangement is to work remotely for 3 days of my 5 day week, travelling in to the office on two consecutive days, typically Wednesday and Thursday.  This tends to break up my week very nicely in to easy chunks: Monday-Tuesday at home, Wednesday-Thursday in office, Friday at home, and then the weekend.  This in itself is one of the biggest advantages in my view; I get 3 &#8216;fresh starts&#8217; per week where I can be ultra-productive.  Rarely do I now get &#8216;that Friday Afternoon feeling!   Following are some tips I have if you are about to start working remotely (and a lot of these points apply to freelance workers too)</p>
<h3><span id="more-199"></span>Tip: Have your own work space or room</h3>
<p>In our house I am fortunate enough to have reserved the &#8216;box room&#8217; bedroom for the sole purpose of serving as my office.  This gives me an opportunity to enter &#8216;a work environment&#8217; and close the door on home (and vice versa at the end of each day).  This focuses the mind on work matters and keeps me from being distracted by the massive amount of DIY work that remains incomplete in our house at the moment.  I recall reading articles before I asked for this arrangement with regards to <a href="http://www.alistapart.com/articles/habit-fields/" target="_blank">habit fields</a>, and really am a believer in this concept.  I think I would find remote-working so much more difficult if I had to sit somewhere that also served as a relaxation area.</p>
<h3>Tip: Set up your working environment properly</h3>
<p>Set up your working environment as if you were in an office for a company.  By this, I mean everything; ranging from the bare bones of your work environment to your software setup.  Actually pay attention to health and safety regulations with regards to monitor and keyboard/mouse use; make sure your chair is correctly adjusted (and is adjustable at all! Don&#8217;t work on a dining chair!) &#8211; in my early days as a freelancer I used to sit on a non-adjustable chair for about 5 hours a day and ended up needing physiotherapy on my lower back as I was in utter agony.</p>
<p>Try not to compromise on your software setup either.  Install the same FTP client you use at work, and configure your IDE or text editor in the same way as your work, including indentation and layout settings; it&#8217;s amazing how a little effort to get the environment consistent can make your life so much easier.  My advice extends to, if possible, having a computer for work and a laptop for pleasure.  This further extends the separation of work time and play time; if this is financially not viable then a good compromise is to have two users on your desktop machine; one for work and one for personal use.  I&#8217;ll bet your bookmarks for work in your bookmarks toolbar are substantially different to the bookmarks for home in your home bookmarks toolbar!</p>
<p><strong>Keep work and pleasure separate in your software environment too</strong></p>
<p>Moving on from that point, I used to have all of my bookmarks for freelancing and general interests in one bookmarks toolbar folder, meaning BBC News was mixed up with the PHP Manual and a bookmark to my phpmyadmin directory.  This made it <em>too easy</em> to see the BBC news bookmark and check the news for 5 minutes.  5 minutes turns in to 10, in to 15, etc.  Now, I keep my bookmarks separate, by using different browsers. I use Mozilla Firefox for work; and Firefox only has my work bookmarks in it, and I use Google Chrome for pleasure; this has my personal bookmarks in it.  Largely I won&#8217;t even use my desktop PC for &#8216;play&#8217; or &#8216;relaxation&#8217; and try to reserve that stuff for my laptop.</p>
<h3>Don&#8217;t get work done in your house when you&#8217;re supposed to be working</h3>
<p>For the first two days of the remote working arrangement we had ongoing building work.  It is very difficult indeed to get good runs of concentration with the noise, and interaction with the tradesmen.  If you&#8217;re having any considerable work done to your house my advice would be, if possible, to go in office for that period.  It&#8217;s much quieter and you&#8217;ll be much more productive.</p>
<h3>Communication</h3>
<p>Assuming you are moving from an office environment, you will be used to being tapped on the shoulder and asked questions, and being asked for updates on the state of work on a fairly regular basis.  Though these distractions are often labelled unnecessary and irritating, they naturally lessen in frequency if you&#8217;re not in the office.  This doesn&#8217;t mean that you should make yourself completely impossible to contact!  I ensured I invested in an unlimited call plan on a home number so that I can call the office as frequently as needed to ask questions to which I need immediate answers, and so that the office have a reliable line on which they can contact me.  Thus far I have more than made good use of the phone line!</p>
<p>Your project manager will largely appreciate frequent, detailed updates of your progress.  There&#8217;s nothing worse than having a developer working for a solid few days with no good indication of where they are at with a project.  It&#8217;s good to say &#8220;all&#8217;s going well and we&#8217;re on time&#8221; and it&#8217;s responsible to inform if you&#8217;re having difficulties and look to be struggling to deliver for the target time.</p>
<h3>Work Time</h3>
<p>Something said fairly frequently to me is &#8220;oh so you can work whenever you want then&#8221;.  I&#8217;m not sure that this is entirely true, and my advice would always be to try to be at your desk between the hours that your office would normally be open (in my case 9am to 5pm).  This means:</p>
<ul>
<li>You are contactable via email and on the phone all day, should you be needed.</li>
<li>You maintain a fairly normal working life and have similar spare time as other people (provided your friends work normal hours!)</li>
<li>You are guaranteed to put in the required number of hours per week.</li>
</ul>
<div>I know that I would find it very difficult, for example, to start working at 1pm and work through to 9pm while all of my friends relax and enjoy themselves.  It&#8217;s easy to maintain the discipline of being &#8216;at work&#8217; from 9 until 5!</div>
<h3>Quick advice for those who do freelance work alongside a full time job</h3>
<ul>
<li>The hours of 9am &#8211; 5pm are strictly your company&#8217;s time.  Make your freelance clients aware of this. Break the rule for <strong>noone</strong>.  <em>In my opinion, to freelance when you&#8217;re being paid to work by someone else is criminal!</em></li>
<li>You will find it much more difficult to motivate yourself to freelance after having spent 8 hours each day working in your own house (I used to find working 12 hour days fairly easy if 8 hours were in-office and 4 hours at home).  My solution to this is to work in my office for work, and to move to the sofa on a laptop to freelance.  This does break slightly from my laptop == pleasure rule but at least gives me some separation in terms of the type of work I do!</li>
</ul>
<h3>Summary</h3>
<p>Overall, it took me a week or two to get in to the swing of working remotely full-time, but I&#8217;ve got there now, and it feels good! I get distracted a lot less on an hour-by-hour basis and feel that I get more done in terms of pure development, and also the three segments to each working week really help me with maintaining my productivity at a high level right from Monday morning to Friday afternoon.  For any employee with the option of working remotely: give it a go, but only if you can separate work and home properly!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edwardyarnold.co.uk/blog/working-from-home-month-1/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Distractions &#8211; a useful Firefox plugin to stop them in their tracks</title>
		<link>http://www.edwardyarnold.co.uk/blog/distractions-a-useful-firefox-plugin-to-stop-them-in-their-tracks</link>
		<comments>http://www.edwardyarnold.co.uk/blog/distractions-a-useful-firefox-plugin-to-stop-them-in-their-tracks#comments</comments>
		<pubDate>Thu, 31 Mar 2011 08:30:34 +0000</pubDate>
		<dc:creator>Ed Yarnold</dc:creator>
				<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.edwardyarnold.co.uk/blog/?p=183</guid>
		<description><![CDATA[At work, I occasionally found that if faced with a particularly mundane piece of work, or something that dragged out for a long period of time, it would be quite easy to get distracted by popular sites such as twitter, BBC news, engadget and various other tech-related but not entirely productive sites. I thought &#8220;someone [...]]]></description>
			<content:encoded><![CDATA[<p>At work, I occasionally found that if faced with a particularly mundane piece of work, or something that dragged out for a long period of time, it would be quite easy to get distracted by popular sites such as twitter, BBC news, engadget and various other tech-related but not entirely productive sites.</p>
<p>I thought &#8220;someone else must have had this problem&#8221;, and if they hadn&#8217;t, I was going to write a Firefox Add On to help maintain productivity by blocking distraction web sites.  But, alas, someone has beaten me to it! I have found and installed the <a href="https://addons.mozilla.org/en-US/firefox/addon/leechblock/">LeechBlock</a> Firefox add on and it is fantastic. I&#8217;ve added my favourite sites to a list of sites to block at any time that isn&#8217;t a break time (so here, 9-11, 11.15-1, 1.30-3, 3.15-5) and it&#8217;s proven very effective.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edwardyarnold.co.uk/blog/distractions-a-useful-firefox-plugin-to-stop-them-in-their-tracks/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux: How to recursively download contents of an FTP directory</title>
		<link>http://www.edwardyarnold.co.uk/blog/linux-how-to-recursively-download-contents-of-an-ftp-directory</link>
		<comments>http://www.edwardyarnold.co.uk/blog/linux-how-to-recursively-download-contents-of-an-ftp-directory#comments</comments>
		<pubDate>Tue, 08 Mar 2011 18:21:43 +0000</pubDate>
		<dc:creator>Ed Yarnold</dc:creator>
				<category><![CDATA[Linux Command Line]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.edwardyarnold.co.uk/blog/?p=177</guid>
		<description><![CDATA[I was looking for a quick way to recursively download the entire FTP directory for a site that we are transferring. This was, I found, the easiest and most straightforward way: On the command line interface, assuming you have wget installed, type: wget -r ftp://USERNAME:PASSWORD@mysite.com/ Hit enter and wait while it retrieves everything for you. [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking for a quick way to recursively download the entire FTP directory for a site that we are transferring.  This was, I found, the easiest and most straightforward way:</p>
<p>On the command line interface, assuming you have wget installed, type:</p>
<p><code>wget -r ftp://USERNAME:PASSWORD@mysite.com/</code></p>
<p>Hit enter and wait while it retrieves everything for you.</p>
<p>I did it this way because I didn&#8217;t want to download 4gb of data to upload again, so ran this command direct from the &#8216;production&#8217; server with its stupidly fast internet connection. Hours and hours saved!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edwardyarnold.co.uk/blog/linux-how-to-recursively-download-contents-of-an-ftp-directory/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A problem with forms submitting using AJAX: how to resubmit?</title>
		<link>http://www.edwardyarnold.co.uk/blog/ajax-form-problem-resubmissio</link>
		<comments>http://www.edwardyarnold.co.uk/blog/ajax-form-problem-resubmissio#comments</comments>
		<pubDate>Tue, 22 Feb 2011 23:57:04 +0000</pubDate>
		<dc:creator>Ed Yarnold</dc:creator>
				<category><![CDATA[Best Practice]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Usability]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.edwardyarnold.co.uk/blog/?p=167</guid>
		<description><![CDATA[I&#8217;m a fairly regular user of the twitter web front-end, and of Facebook. Both of these have tremendously wide audiences and are hugely popular. Twitter recently attracted a bit of negative press from the technical community for replacing the old, fairly standard URL structure with one that uses &#8216;hashbangs&#8217; and is fully dependent upon Javascript [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a fairly regular user of the twitter web front-end, and of Facebook.  Both of these have tremendously wide audiences and are hugely popular.  Twitter recently <a href="http://isolani.co.uk/blog/javascript/BreakingTheWebWithHashBangs">attracted a bit of negative press</a> from the technical community for replacing the old, fairly standard URL structure with one that uses &#8216;hashbangs&#8217; and is fully dependent upon Javascript to serve the correct content.  But I&#8217;ve another more user-centred complaint about Twitter (and Facebook) relying heavily on Javascript for fundamental parts of their apps (e.g. the ability to tweet, and ability to comment on stuff).  That is the removal of the ability to &#8216;refresh&#8217; or &#8216;resubmit&#8217; a request&#8230;<br />
<span id="more-167"></span><br />
Let me give some background.  I live in quite a rural location, where the broadband is far from perfect.  My packet loss rate is higher than desired which means that sometimes requests for web pages or web services fail in some way.  This is not normally a problem; if the page partially loads or stops loading, I hit refresh and generally get the whole page.  All fine!</p>
<p>In &#8216;the olden days&#8217; when processes such as updating your Facebook status or posting a tweet were done through bog standard HTML forms posted by the browser to a new page request, it didn&#8217;t matter when the page I was posting to didn&#8217;t get posted to fully, or didn&#8217;t respond, because I could hit refresh (or press the submit button again or whatever) and the request would be resubmitted.</p>
<p>Some web developers (myself, at times, included) HATE impatient users who will press buttons twice or refresh the page because it&#8217;s taking too long.  In a lot of apps this means that the action is applied however many times the button is pushed (e.g., two or three orders are placed instead of one). But the reality is, sometimes there is a genuine need to refresh or resubmit, because nothing is *ever* going to happen with the first request that was sent.  This could be due to an internet connection problem or a server-side problem.</p>
<p>Now, more and more web sites seem to favour the &#8220;no new pageload is necessary&#8221; approach which, in itself, I do not have a problem with &#8211; at all.  What I do have a problem is is when the developers choose to disable the submit button once I press it &#8211; permanently.  Because if nothing happens for 2 or 3 seconds, I am pretty damn sure that that status update or tweet is never going to get posted.  What I would like to do at this stage is to resubmit the request.  But at this time, there is no easy way to do this:</p>
<ul>
<li>I have not requested the page in a traditional sense in the browser, so I can not push the &#8216;refresh&#8217; button; that would reload the whole page and typically delete the tweet or status update that I have written.</li>
<li>The submit button for the form is permanently disabled, so I can&#8217;t press it again to submit again.</li>
</ul>
<p>Even if the JS implementation gracefully degrades (e.g. if I have no JS support I get the &#8220;old fashioned&#8221; style normal form), this situation occurs for people with JS enabled.  Just because a user has JS enabled doesn&#8217;t mean that their web connection is faultless or that they won&#8217;t need to push that submit button twice!</p>
<p>I was trying to think of a way around this issue that doesn&#8217;t require scrapping the AJAX submission all together, and came up with only one potential solution, which is to disable the submit button but only for an elected period of time (say 2 or 3 seconds), so that if the request doesn&#8217;t get responded to in that time, the user is given an opportunity to re-submit.</p>
<p>Anyone else&#8217;s ideas of how to work around this problem would be gratefully received through the comments section; I don&#8217;t want to write software that frustrates people in the same way that this frustrates me!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edwardyarnold.co.uk/blog/ajax-form-problem-resubmissio/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Does your website still need to be functional with Javascript disabled or unsupported?</title>
		<link>http://www.edwardyarnold.co.uk/blog/does-your-website-still-need-to-be-functional-with-javascript-disabled-or-unsupported</link>
		<comments>http://www.edwardyarnold.co.uk/blog/does-your-website-still-need-to-be-functional-with-javascript-disabled-or-unsupported#comments</comments>
		<pubDate>Wed, 10 Nov 2010 08:43:37 +0000</pubDate>
		<dc:creator>Ed Yarnold</dc:creator>
				<category><![CDATA[Best Practice]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Optimisation]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.edwardyarnold.co.uk/blog/?p=149</guid>
		<description><![CDATA[We have recently been reviewing the amount of development time spent on projects, and have identified one area where a fair chunk of extra time is spent for relatively little gain: Ensuring that web sites are 100% functional with Javascript disabled. The general concensus on the web is that year on year, the number of [...]]]></description>
			<content:encoded><![CDATA[<p>We have recently been reviewing the amount of development time spent on projects, and have identified one area where a fair chunk of extra time is spent for relatively little gain: Ensuring that web sites are 100% functional with Javascript disabled.  The general concensus on the web is that year on year, the number of people (even those technical in nature that browse w3schools) with javascript disabled <a href="http://www.w3schools.com/browsers/browsers_stats.asp">is falling</a> &#8211; but is this a decent reason to consider removing the true graceful degradation that most front end developers have been obsessed with for the last few years?<br />
<span id="more-149"></span></p>
<p>The main reason for Javascript being used to progressively enhance the user experience rather than be a fundamental &#8216;requirement&#8217; is cited as making the site accessible to as many people as possible.  Importantly, many mobile devices don&#8217;t fully support Javascript (Smart Phones tend to, but I&#8217;m talking true mobile phones here) and screen readers certainly don&#8217;t support Javascript.  Realistically, the percentage of visitors falling in to the &#8216;browsing on a mobile device&#8217; or &#8216;using a screen reader&#8217; will be low, and often low enough for a client (or yourself) to make the judgement &#8220;we&#8217;re not going to bother&#8221;.  It is important to consider that there are advantages to graceful degradation other than making the site as accessible as possible:</p>
<p><strong>Google, Bing, and A.N.Other search engines</strong> &#8211; search engine spiders are still fairly basic creatures.  If your site navigation doesn&#8217;t load a new page but instead loads new content in using Ajax when you click the &#8216;About&#8217; link, how are search engines going to find and index your &#8216;About&#8217; page content if the site is not navigable without Javascript?  It&#8217;s quite simple to make things like this degrade; if Javascript is disabled the link should go to index.php?page=about rather than nowhere.  Importantly, many clients think that <strong>google is the most important visitor</strong>; if they&#8217;ve forced you to put lots of keywords at the bottom of the site despite your pleas for them not to then they wouldn&#8217;t be very pleased to find out that the search engines can&#8217;t get any further than your home page.</p>
<p><strong>Application Design</strong> &#8211; Designing the application so that it works without Javascript and then adding Javascript afterwards often makes the system architecture much more understandable and &#8216;rigid&#8217;.  In fact, if done correctly, this can speed up the Javascript implementation process.  Looking back to our previous example, index.php?page=about will load a completely new version of the page with header, footer and all the bells and whistles.  How about, if you click the &#8216;About&#8217; link with javascript enabled, it will load index.php?page=about but through AJAX?  Using HTTP_X_REQUESTED_WITH we can detect that it was requested through AJAX and serve just the &#8216;meaty&#8217; bit of the page; ie the content that is changing, rather than the whole page.  Does this really add much time to the development process?  In my opinion, no it doesn&#8217;t!</p>
<p>Of course, the user experience will not be identical without javascript, but in my view it is still important to support users with no support for the language on their device, or even those that choose to browse without it.  It is my view that you can treat support for when Javascript disabled in the same way as many designers treat support of Internet Explorer 6: The site should work, but it doesn&#8217;t necessarily have to be perfect.  Sticking to this general guideline will not add huge amounts of time to the development time of a project, and if it does&#8230; you should take a look at how the system is designed, because it really shouldn&#8217;t.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edwardyarnold.co.uk/blog/does-your-website-still-need-to-be-functional-with-javascript-disabled-or-unsupported/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Commenting code &#8211; a minor but invaluable investment of time</title>
		<link>http://www.edwardyarnold.co.uk/blog/commenting-code-invaluable-investment-of-time</link>
		<comments>http://www.edwardyarnold.co.uk/blog/commenting-code-invaluable-investment-of-time#comments</comments>
		<pubDate>Wed, 03 Nov 2010 18:56:04 +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=133</guid>
		<description><![CDATA[I&#8217;m a strong believer in code being written in such a way that it is self documenting, but would not use this as an excuse for not adding in English language comments to go alongside the code. After all, comments add a tiny amount to the size of a PHP file and don&#8217;t slow down [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a strong believer in code being written in such a way that it is self documenting, but would not use this as an excuse for not adding in English language comments to go alongside the code.  After all, comments add a tiny amount to the size of a PHP file and don&#8217;t slow down the application at all.  Also, the English language comments alongside the code can be used to justify decisions or assumptions you have made, which might make the next programmer&#8217;s visit to the file a lot quicker and more productive.</p>
<p><span id="more-133"></span></p>
<h3>Explaining and justifying your decisions</h3>
<p>At the most very basic level, take this bit of code for example:</p>
<p><code>ksort($files);</code></p>
<p>To most PHP developers it is obvious that this bit of code sorts the $files array in key order.  But it is not obvious to any PHP developer *why* I have done this.  Adding a comment to say what I am doing and why would help speed up the recognition of what this code does; but more importantly, explain why this code is here.:</p>
<p><code><br />
/**<br />
 * Sort the $files array in Key order. We want them displayed on the<br />
 * page in added order,  and the $files array is not necessarily<br />
 * sorted in that order before this stage.<br />
 */<br />
ksort($files);<br />
</code></p>
<h3>Using code comments as a tool: Autocompletion</h3>
<p>There are other areas of an application where documentation can be even more useful.  Modern Code Editors and IDEs will read what are called &#8216;<a href="http://en.wikipedia.org/wiki/PHPDoc#DocBlock">docblocks</a>&#8216; at the top of class, method or function definitions and add the information in the docblock in to your autocomplete prompts.  So how do these docblocks work?</p>
<p>Docblocks are generally in this format (opened by /**, closed by */, with a * at the start of every line inbetween) and always apply to the next uncommented line of code.  In this case, the line of code beginning with $page_posted_to = is documented by the docblock above.:</p>
<p><code><br />
/**<br />
 * Determine if the page has been posted to with an action.<br />
 */<br />
$page_posted_to = (array_key_exists('action', $_POST) &#038;&#038; !empty($_POST['action']));<br />
</code></p>
<p>Within docblocks you can contain &#8216;tags&#8217;.  These &#8216;tags&#8217; begin with an @ symbol and are often read or interpreted by documentation generation utilities or IDEs/Editors for autocompletion.  A comprehensive list can be found on the <a href="http://en.wikipedia.org/wiki/PHPDoc#Tags">Wikipedia page for Docblocks</a>.   Using these tags can encourage you to include information in your documentation that you might forget to include normally, ie the expected data type of function parameters.</p>
<p>At it&#8217;s most basic use, docblocks usually look something like this when describing a function or method:</p>
<p><code><br />
/**<br />
 * This function adds two values together<br />
 * @param int $a The first value<br />
 * @param int $b The second value<br />
 * @return int The value of $a + $b<br />
 */<br />
function add_together($a, $b) {<br />
     return $a + $b;<br />
}<br />
</code></p>
<p>As you can see, including these docblocks explains in plain english what the function does, what parameters it expects, and what it will return.  This can save the next developer that reads your code tonnes of time and headaches, but most importantly of all, will make your code editor or IDE (if it supports autocompletion and docblock parsing) much more intelligent when it comes to helping you call your own methods or functions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.edwardyarnold.co.uk/blog/commenting-code-invaluable-investment-of-time/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

