<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Ben Poole</title>
<link>http://benpoole.com</link>
<language>en-gb</language>
<description>Ben Poole: last 10 &#8217;blog entries filed under &#8220;Programming&#8221;</description>
<copyright>Copyright 1997 - 2013, Benedict Poole</copyright>
<generator>Domino SimpleFeed from http://foo-soft.com</generator>
<webMaster>site@benpoole.com (Ben Poole)</webMaster>
<atom:link href="http://benpoole.com/bp.nsf/blogs-cat.rss" rel="self" type="application/rss+xml" />
<item><title>How to win the love of a developer</title><pubDate>Sat, 13 Oct 2012 10:48 +0100</pubDate><description><![CDATA<p>Remember <a href="http://www.joelonsoftware.com/articles/fog0000000043.html" title="Link to Joel Spolsky, “The Joel Test: 12 Steps to Better Code”">Joel’s Test</a>, with its vital tips on how to make life better and more productive for the average developer (we are <a href="http://redmonk.com/sogrady/2010/09/09/the-new-kingmakers/" title="Link to Stephen O’Grady, “Meet the New Kingmakers: Same as the Old Kingmakers”">kingmakers</a> after all)?</p>

<p>Well, decent equipment, nice offices, ping pong tables and all that—these things pale into utter insignificance when it comes to one, relatively simple change, that organisations can make:</p>

<p class="highlight">Ensure that your test environments mirror those used in production.</p>

<p>It really is that simple, and you will save countless hours of frustrated troubleshooting for your developers, testers, infrastructure and support teams. In organisations large and small I have lost count of the number of times working through an issue has resulted in the same root cause: the deployment to live actually meant testing a particular configuration or integration <em>for the very first time</em>.</p>

<p>This sort of thing is insane. Sort it out, and you will have your developers&#8217; admiration for life.</p>]></description><link>http://benpoole.com/weblog/201210131048</link><dc:subject>programming, programmers, testing</dc:subject><dc:creator>Ben Poole</dc:creator><guid isPermaLink="true">http://benpoole.com/weblog/201210131048</guid><comments>http://benpoole.com/weblog/201210131048#comments</comments></item><item><title>Sublime Text 2</title><pubDate>Tue, 3 Jul 2012 10:29 +0100</pubDate><description><![CDATA<p>Sublime Text 2 <a href="http://www.sublimetext.com/blog/articles/sublime-text-2-0-released" title="Sublime Blog: Sublime Text 2.0 Released">went gold a couple of weeks ago</a>, and I would urge you to <a href="http://www.sublimetext.com/2">give it a spin</a>. For straight-ahead web development, <a href="http://www.panic.com/coda">Coda 2</a> is still my weapon of choice, but Sublime Text 2 is lovely for PHP, Ruby, the odd bit of Java when not using the Eclipse behemoth, etc. For the last twelve years the venerable <a href="http://textpad.com/">TextPad</a> has always been my stable editor in my Windows virtual machines, but guess what? Sublime Text 2 has supplanted it.</p>

<p>A great tool, well worth the (small) price. And it does Linux too.</p>

<p>(Talking of Coda 2, if you use it be sure to check out the tips on the Panic blog: <a href="http://www.panic.com/blog/2012/07/top-20-secrets-of-coda-2/">Top 20 Secrets of Coda 2</a>).</p>]></description><link>http://benpoole.com/weblog/201207031029</link><dc:subject>editors, sublime text 2, programming, tools</dc:subject><dc:creator>Ben Poole</dc:creator><guid isPermaLink="true">http://benpoole.com/weblog/201207031029</guid><comments>http://benpoole.com/weblog/201207031029#comments</comments></item><item><title>Kicking the Eclipse habit</title><pubDate>Thu, 17 May 2012 21:21 +0100</pubDate><description><![CDATA<p>Eclipse is a wondrous piece of work, and extremely useful. I have cooked up many lines of code in that <abbr title="Integrated Development Environment">IDE</abbr> over the years (I’ve deleted lots of lines in it too, which is as it should be), and will probably bust it out again and again in the future. But for now? For now I’ve parked it. Too many <abbr title="User Interface">UI</abbr> quirks getting in the way, too many dependent pieces of code ’n’ plug-ins, too much waiting for “tooling” to pull its trousers up. I like it simple: one or three bare-bones editors, and the command line.</p>

<p>It’s always good to compare with fellow developers, and I always like to hear what kit people are using. I’ll start: here’s the current tool-set getting the love <i><a href="http://foo-soft.com" title="Foo Software. That’s my business don’t you know">chez Foo</a></i>&hellip;</p>

<dl>
  <dd><a href="http://sublimetext.info/">Sublime Text 2</a> (all main platforms)</dd>
  <dt>Great programming editor, loads of syntax files built-in, and cross-platform in a <em>good</em> way. Really like using this, and it’s my PHP / Ruby editor of choice at the moment (not that I do much Ruby, but I can dream).</dt>
  <dd><a href="http://www.panic.com/coda/">Coda</a> (OS X)</dd>
  <dt>Venerable editor for all things web plus a few others. Still a big favourite but needs a version bump—and soon.</dt>
  <dd>A terminal</dd>
  <dt>So flexible, oh the things you can do! It has its own range of editors (my fave is vi) plus <a href="http://git-scm.com/">git</a>, ssh, <a href="http://subversion.apache.org/">svn</a>, maven, phing, all the rest&hellip; <span class="smiley smile">:-)</span></dt>
</dl>

<p>&#8212;Oh yes, the main languages and environments I’m flailing at with these tools are PHP, <abbr title="HyperText Markup Language">HTML</abbr>, <abbr title="Cascading Style Sheets">CSS</abbr>, and Javascript (including the splendiferous <a href="http://pivotal.github.com/jasmine/">Jasmine</a>&#8212;more on that later).</p>]></description><link>http://benpoole.com/weblog/201205172121</link><dc:subject>ide, programming, tools, eclipse</dc:subject><dc:creator>Ben Poole</dc:creator><guid isPermaLink="true">http://benpoole.com/weblog/201205172121</guid><comments>http://benpoole.com/weblog/201205172121#comments</comments></item><item><title>HTTP 701 meh</title><pubDate>Sat, 28 Jan 2012 17:09 +0100</pubDate><description><![CDATA<p>Hopefully you are a <a href="https://github.com">github regular</a> and have already seen this README, but just in case not, be sure to check out John Barton’s RFC for some extra HTTP codes. My favourites are 701 and 748.</p>

<p><a href="https://github.com/joho/7XX-rfc#readme">John Barton&#8217;s RFC</a>.</p>]></description><link>http://benpoole.com/weblog/201201281709</link><dc:subject>http, github, fun</dc:subject><dc:creator>Ben Poole</dc:creator><guid isPermaLink="true">http://benpoole.com/weblog/201201281709</guid><comments>http://benpoole.com/weblog/201201281709#comments</comments></item><item><title>More on testable code</title><pubDate>Wed, 25 Jan 2012 19:23 +0100</pubDate><description><![CDATA<p>Following on from <a href="/weblog/201201170736">my previous post</a>, I stumbled across a most excellent resource, Miško Hevery&#8217;s <a href="http://misko.hevery.com/code-reviewers-guide/">Guide: Writing Testable Code</a>. This is detailed, helpful and above all eminently readable&#8212;well worth running off and keeping.</p>

<p>Hevery&#8217;s document contains a number of tips designed to make code more testable, but really it goes wider than that. Hevery picks out four basic flaws, gives examples of each, how to detect them (&#8220;warning signs&#8221; if you will), and of course, how to address them.</p>

<p>The four flaws:</p>

<ol>
<li>&#8220;Constructor does real work&#8221; (don&#8217;t do any more than basic assignment, and certainly don&#8217;t do any static &#8220;initialisation&#8221; method calls)</li>
<li>&#8220;Digging into collaborators&#8221; (avoid a deep chain of wrapper objects)</li>
<li>&#8220;Brittle global state &amp; singletons&#8221; (globally-accessible elements can / will cause havoc when trying to test and debug)</li>
<li>&#8220;Class does too much&#8221; (remember the classic principle of &#8220;single responsibility.&#8221; Also, spaghetti code is blummen&#8217; hard to test)</li>
</ol>

<p>Read more&hellip; <a href="http://misko.hevery.com/code-reviewers-guide/">Guide: Writing Testable Code</a>.</p>]></description><link>http://benpoole.com/weblog/201201251923</link><dc:subject>programming, testing, tips, miško hevery</dc:subject><dc:creator>Ben Poole</dc:creator><guid isPermaLink="true">http://benpoole.com/weblog/201201251923</guid><comments>http://benpoole.com/weblog/201201251923#comments</comments></item><item><title>Making code test-able</title><pubDate>Tue, 17 Jan 2012 07:36 +0100</pubDate><description><![CDATA<p>There are two things a developer needs to make his or her output testable (and therefore more robust. Hopefully):</p>

<ol>
<li>The &#8220;How would I test for xyz&#8221; mind-set, and;
<li>A fast simple development environment</li>
</ol>

<p>That&#8217;s it, that&#8217;s all you need. The first comes with practise, and the second is pretty straightforward nowadays. Of late I have been writing a lot of PHP in <a href="http://eclipse.org">Eclipse</a>, <a href="http://panic.com/coda/">Coda</a> and the new kid on the block, <a href="http://www.sublimetext.com/2">Sublime Text 2</a> (check it out: very nice). All of these tools make it easy to write test-able code, because one simply pulls in the unit testing framework of choice, and then one writes code: job done, very low barrier to entry.</p>

<p>As a small aside, I am constantly amazed at how much PHP stuff goes out the door with minimal-to-no tests, especially when one considers the fluid nature of the language (its typing and such). This contrasts sharply with the mind-set we see amongst Rubyists, who regard their language&#8217;s dynamism as <i>raison d&#8217;être</i> for excellent test coverage.</p>

<p>So a diligent approach to testing is one thing, but contrast my comments about editors above with other recent experiences writing Java in an Eclipse-based editor called Domino Designer (some of you may be familiar with it). Making <em>that</em> code test-able has been more problematic, given DDE&#8217;s reluctance to play nice with plug-ins like <a href="http://junit.org">JUnit</a>, and the way a typical Java agent is structured. So, a couple of tips:</p>

<ol>
<li>Abstraction is key: write as much of your Java code as you can abstracted away from the Domino object model. This way you can code in a proper Eclipse instance, and you can write easy test cases. Break up big problems into small solvable components, and test them. Your Java agents should be very &#8220;light&#8221;&#8212;minimal code perhaps just looping a collection or whatever. Let your custom, tested classes do the heavy lifting.</li>
<li>If you&#8217;re like me, and not at Lotusphere, you will be missing out on a session from Messrs. <a href="http://www.stickfight.co.uk">Myers</a> and <a href="http://www.nsftools.com">Robichaux</a> covering effective Java in the Domino environment. As soon as their presentation is made available, I have it on good authority that you will want it, and that the Wookiee has some tricks up his sleeve when it comes to JUnit <span class="smiley smile">:-)</span>.</li>

<p>(Finals words of &#8220;wisdom&#8221;: it is a lot quicker, and simpler, to write test-able code up-front. Adding tests after the fact is always more burdensome).</p>]></description><link>http://benpoole.com/weblog/201201170736</link><dc:subject>testing, programming</dc:subject><dc:creator>Ben Poole</dc:creator><guid isPermaLink="true">http://benpoole.com/weblog/201201170736</guid><comments>http://benpoole.com/weblog/201201170736#comments</comments></item><item><title>Resolutions for coders</title><pubDate>Thu, 5 Jan 2012 18:45 +0100</pubDate><description><![CDATA<p><a href="http://benpoole.com/bp.nsf/weblog/201201042230" title="Link to my post &#8220;Code Year and Site Design&#8221;">Yesterday</a> I posted about <a href="http://codeyear.com">Code Year</a>, an initiative to get people learning the gentle (chortle) art of programming. But what of the seasoned professional, the much-maligned code monkey, the long-suffering developer?</p>

<p>Well, <a href="http://matt.might.net">Matt Might</a> has a splendid list of twelve resolutions for the rest of us:</p>

<p>Matt Might, <a href="http://matt.might.net/articles/programmers-resolutions/">12 Resolutions for Programmers</a>.</p>]></description><link>http://benpoole.com/weblog/201201051845</link><dc:subject>programming, matt might, resolutions</dc:subject><dc:creator>Ben Poole</dc:creator><guid isPermaLink="true">http://benpoole.com/weblog/201201051845</guid><comments>http://benpoole.com/weblog/201201051845#comments</comments></item><item><title>Codeyear and site design</title><pubDate>Wed, 4 Jan 2012 22:30 +0100</pubDate><description><![CDATA<p>After checking out the <a href="http://codeyear.com">Code Year</a> site recently launched by <a href="http://www.codecademy.com">Codecademy</a>, I moved on to read an interesting post from that site&#8217;s designer, Sacha Greif: <a href="http://sachagreif.com/how-i-designed-codeyear-com-in-1-hour/">How I Designed CodeYear.com in 1 Hour</a>. Definitely check this post out: Sacha deftly guides the reader through the over-arching thought processes behind an effective site re-design. There are some handy tips and links along the way for any budding designers, or coders like you and I who simply want to to create more pleasant web experiences.</p>

<p>As for Code Year, what a great initiative!</p>

<blockquote cite="http://www.rushkoff.com/blog/2010/3/25/program-or-be-programmed.html">If you are not a programmer, you are one of the programmed. It&#8217;s that simple.</blockquote>

<p><a href="http://www.rushkoff.com/blog/2010/3/25/program-or-be-programmed.html" title="Link to Douglas Rushkoff, &#8220;Program or Be Programmed&#8221;">Douglas Rushkoff</a> says it best.</p>]></description><link>http://benpoole.com/weblog/201201042230</link><dc:subject>codeyear, douglas rushkoff, programming, codecademy</dc:subject><dc:creator>Ben Poole</dc:creator><guid isPermaLink="true">http://benpoole.com/weblog/201201042230</guid><comments>http://benpoole.com/weblog/201201042230#comments</comments></item><item><title>Friday posers…</title><pubDate>Fri, 9 Sep 2011 16:41 +0100</pubDate><description><![CDATA<p>Recent projects have meant lots and lots of Javascript. Other work has led to a need to really <em>study</em> the language, and look into more than the odd <a href="http://jquery.com">jQuery</a> plugin and wot-not. This has been a rewarding experience: challenging received wisdom, ensuring that I know more about all those concepts that spend years just floating out there on the edge of one&#8217;s understanding.</p>

<p>To that end, here are a few interesting tid-bits which I have found&#8212;typically whilst researching more involved stuff like prototypical inheritance and closures <span class="smiley smile">:-)</span>. It&#8217;s amazing how much we <em>think</em> we know&hellip;</p>

<p>A couple of the more involved posers have specimen answers attached; the others are too easy for me to do that! It&#8217;s all interesting though:</p>

<pre class="prettyprint">// What do these two alerts produce, and why?
alert('1' + 3);
alert('3' - 1);

// If expressed as tests, what do each of these return?
"1" == 1;
"1" === 1;
"1" == true;
"1" === false;

// What do these calls produce?
parseInt("05");
parseInt("010");
parseInt("09");

// What are the five main data types in Javascript?

// How would you create a class in Javascript, with a private method?
function MyClass()
{
    function somePrivateMethod() {
        console.log("this is a private method");
    }
}

//… how would you add a public method to this class?
MyClass.prototype = {
    somePublicMethod: function() {
        console.log("This is a public function, whoop!");
    }
}</pre>]></description><link>http://benpoole.com/weblog/201109091641</link><dc:subject>javascript, programming, fun, tips</dc:subject><dc:creator>Ben Poole</dc:creator><guid isPermaLink="true">http://benpoole.com/weblog/201109091641</guid><comments>http://benpoole.com/weblog/201109091641#comments</comments></item><item><title>HTML5 field types (in brief)</title><pubDate>Thu, 18 Aug 2011 11:44 +0100</pubDate><description><![CDATA<p>If you&#8217;ve been following some of my recent posts on off-line apps, Web SQL and all that, you will have seen that all my mark-up snippets were in HTML5. And no doubt you have seen a lot of the brou-ha-ha around HTML5 too, and probably know that introduces some more field types and attributes.</p><p>Rather than go into a whole exposition of HTML5 (which <a href="http://diveintohtml5.org" title="Link to Mark Pilgrim&#8216;s excellent &#8220;Dive Into HTML5&#8221;">others have already done brilliantly</a>) I want to take a moment at some real-life applications of some of this HTML5 lark. I&#8217;ve already talked about off-line web apps and using local storage options (in the form of Web SQL), so let&#8217;s take a brief look at fields. I&#8217;ve coded a few production sites and applications so far that take advantage of the new types offered in HTML5 (specifically email, number, range and date fields), and having these expanded options in one&#8217;s arsenal is not to be sniffed-at. What I especially like in HTML5 is the in-built support for the new &#8220;placeholder&#8221; attribute. No more do we have label and Javascript <code>onfocus()</code> hacks (at least, not in some browsers). Instead, this wee bit of mark-up does everything we need, with the placeholder text disappearing and re-appearing as the field contents are changed (you will have seen this in <a href="http://benpoole.com/bp.nsf/weblog/201106302211" title="More local Web SQL">my previous demo</a>):</p><pre class="prettyprint">&lt;label for="winklename"&gt;Your winkle&#8217;s name&lt;/label&gt;
&lt;input name="winklename" id="winklename" placeholder="Winkle's full name, e.g. 'Pansy Trueshell'"/&gt;</pre><p><img class="feature-image" src="http://benpoole.com/bp.nsf/files/html5fields/$file/placeholder.png" width="429" height="65" alt="Screenshot of placeholder feld mark-up in action" /></p><p>Isn&#8217;t that smashing ladies and gentlemen? Of course, it&#8217;s not (yet) all roses in the HTML5 garden: some browsers simply don&#8217;t support every bit of this emerging standard. A fine idea is to make use of something like <a href="http://www.modernizr.com">Modernizr</a> for feature detection, but if placeholder support is a feature you need to test for explicitly, something like this should help:</p>
<pre class="prettyprint">function placeholderSupport(){
  return 'placeholder' in document.createElement('input');
}</pre><p>(This function returns <samp>true</samp> for sensible browsers like Safari, Chrome and Firefox, and <samp>false</samp>, predictably, for things like IE8). Now, what I <em>really</em> like is that by introducing new data types for fields, HTML5 also allows the easy manipulation of said fields in the app framework of your choice. So, if I want a whizzy date-picker for my date fields, or a lovely slider for my range fields, it all becomes a hell of a lot easier to apply with a decent framework. For example, here&#8217;s an HTML5 date field which is rendered using the <a href="http://dev.jtsage.com/jQM-DateBox/">DateBox</a> plugin alongside <a href="http://jquerymobile.com">jQuery Mobile</a>:</p>
<p><img class="feature-image" src="http://benpoole.com/bp.nsf/files/html5fields/$file/datebox.png" alt="Screenshot of datebox plugin on a date field" height="428" width="526" /></p><p>A corollary of these new field types is that many mobile devices support them. So, for example, if I want my mobile device&#8217;s keyboard to show an @ sign when filling in an email field, I just need to ensure the field type is set appropriately&#8212;iOS / Android / You Name It will do the rest for me. You&#8217;ve probably seen this in action yourself. So, make sure your apps play nice&#8212;mobile is crucial!</p>]></description><link>http://benpoole.com/weblog/201108181144</link><dc:subject>html5, web design, mobile, html, tips</dc:subject><dc:creator>Ben Poole</dc:creator><guid isPermaLink="true">http://benpoole.com/weblog/201108181144</guid><comments>http://benpoole.com/weblog/201108181144#comments</comments></item>	</channel>
</rss>
