<?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>David Bushell - Web Design &#38; Front-end Development</title>
	<atom:link href="http://dbushell.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://dbushell.com</link>
	<description>David Bushell make websites. I help small businesses, start-ups, individuals, and fellow web agencies make the most of their web presence.</description>
	<lastBuildDate>Wed, 15 May 2013 14:28:12 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Stifling Web Design</title>
		<link>http://dbushell.com/2013/05/15/stifling-web-design/</link>
		<comments>http://dbushell.com/2013/05/15/stifling-web-design/#comments</comments>
		<pubDate>Wed, 15 May 2013 14:28:12 +0000</pubDate>
		<dc:creator>David Bushell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dbushell.com/?p=9067</guid>
		<description><![CDATA[The only way to truly experience and evaluate a website design is in a web browser. That sounds obvious but it bears repeating. While this fact can&#8217;t be denied it is often conceptual design mock-ups that take responsibility for critique and direction. The assumption being that as a more efficient intermediate they&#8217;re good enough. High-fidelity [...]]]></description>
				<content:encoded><![CDATA[<p>The only way to truly experience and evaluate a website design is in a web browser. That sounds obvious but it bears repeating. While this fact can&#8217;t be denied it is often conceptual design mock-ups that take responsibility for critique and direction. The assumption being that as a more efficient intermediate they&#8217;re good enough.</p>
<p><em>High-fidelity</em> design mock-ups have established themselves as a waypoint within the process of website making. Somewhere between the initial briefing and final deployment lies the well honed Don Draper reveal followed by — and who are we kidding? — client sign-off.</p>
<h2>Designing with Code</h2>
<p>Some responsive design aficionados are keen to scoff at this practice. If you&#8217;re not &#8220;designing in the browser&#8221; it&#8217;s time to get with the program. Their manifesto being that design mock-ups in [software of choice] cannot possibly be appropriate any longer.</p>
<p>Has responsive website design really changed the game <em>that</em> much?</p>
<p>Not in the slightest. First and foremost there exists a logically naive assumption that working directly with the medium is a shortcut to success. Or indeed the easiest way to find a solution. Secondly, I&#8217;m raising a bit of a straw man here, I hope. I don&#8217;t for one second believe anyone actually feels liberated designing in code alone without any in-between conceptualisation. It&#8217;s hard to know for sure with all the conference soundbites so often repeated.</p>
<p>Web design, of course, is more than just applying visual style. It requires aspects of user research, information architecture, content hierarchy, state and interaction design. The explosion in web-accessible devices has only highlighted flaws in what was deemed a suitable result.</p>
<p>The browser gives us direct feedback on what&#8217;s becoming an ever more difficult and scrutinised task. With that said, I&#8217;m hard pressed to think of anything more stifling than to use HTML &amp; CSS to achieve the waypoints that lead to a final design. It&#8217;s a horribly tedious and distracting way to express creativity. This idea shuns high-fidelity design mock-ups for another equally inadequate extreme. The browser is a terrible tool for design. Sure, both methods can deliver a website, but are these polar opposites our only option?</p>
<h2>A Matter of Process</h2>
<p>Rather than dropping everything we know — which seems to be the sentiment behind the &#8220;RWD has killed Photoshop&#8221; notion — we need to adjust our process so that we can develop <em>alongside</em> design. <a href="http://alistapart.com/article/gettingrealaboutagiledesign" target="_blank">Agile, not waterfall</a>.</p>
<p>Getting this right allows us to see the actual in-browser experience while design can happen <strong>outside of the browser</strong>. Where it can flourish. Where common sense tells us text rendering will vary. Where imagination allows us to mentally visualise fluid components as we sketch them. Iterate and adapt quickly. Experiment with many mediums.</p>
<p>That doesn&#8217;t mean it&#8217;s ever wrong to make design decisions by editing code now and then — I do it often — but there&#8217;s no reason to impose this limitation. Intermediates exist.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbushell.com/2013/05/15/stifling-web-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Freelance Life</title>
		<link>http://dbushell.com/2013/05/09/freelance-life/</link>
		<comments>http://dbushell.com/2013/05/09/freelance-life/#comments</comments>
		<pubDate>Thu, 09 May 2013 11:21:32 +0000</pubDate>
		<dc:creator>David Bushell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dbushell.com/?p=8882</guid>
		<description><![CDATA[May is my 4th month working self-employed. When I set out in February I didn&#8217;t have many goals other than to escape London and enjoy things a lot more. Half Marathon At the end of May I&#8217;m attempting the Edinburgh half marathon — 21 kilometres of pain! For whatever reason I was fed up last August [...]]]></description>
				<content:encoded><![CDATA[<p>May is my 4th month working self-employed. When I set out in <a href="/2013/02/04/a-new-home/">February</a> I didn&#8217;t have many goals other than to escape London and enjoy things a lot more.</p>
<h2>Half Marathon</h2>
<p>At the end of May I&#8217;m attempting the Edinburgh half marathon — 21 kilometres of pain! For whatever reason I was fed up last August and figured a jog would de-stress. I barely managed 500m but from that day forward running has changed my outlook for the better.</p>
<p>Being a freelancer has given me the flexibility for hour-long runs during the day. I was enjoying the late evening runs exploring East London but those nights weren&#8217;t the most social of activities. I was surprised at how difficult I found the transition to daytime. I suppose it was a lot easier to zone out under moonlight. That and the elevation in the Pennines is a killer.</p>
<p class="post-image"><img alt="Nike Free 3.0 running shoes" src="http://dbushell.com/wp-content/uploads/2013/05/nike-free-3.jpg" /></p>
<p>I run so often now I suppose my career is shaping itself around this training. I&#8217;ll probably do an official marathon at some point to tick it of the bucket list. I&#8217;m not one for organised events though, I just enjoy the simplicity of stepping out into the fresh air.</p>
<h2>Personal Projects</h2>
<p>Aside from general hacking around and blogging, I&#8217;ve already published a couple of projects. The first release for my personal to-do/list app <a href="/2013/04/07/macaque-a-new-project/">Macaque</a> is under regular use. I&#8217;ve also refined and shared my <a href="/2013/04/30/origin/">front-end starting point</a> and <a href="/2013/04/05/the-flat-build-2/">the process</a> behind it. Back in March I gave my first <a href="/2013/03/03/a-responsive-day-out/">conference talk</a> at Responsive Day Out.</p>
<p>I&#8217;m making a conscious effort to limit all work — client or self-initiated — to &#8220;working hours&#8221;. Anything from 6–8 hours per day. Between 9am and 6pm. I want to avoid the temptation of working irregular hours, early or late. That means a choice between paid client work or unpaid self-initiated work. However, I don&#8217;t quite see the latter that way. While income isn&#8217;t direct, I&#8217;d never have landed on my feet had it not been for my writing and projects outside of full-time employment over the last five years.</p>
<p>I see personal projects as my most valuable lead generation skill. To date I&#8217;ve had a pleasant array of clients. A few referrals but most have been enquiries.</p>
<h2>Client Work</h2>
<p>I&#8217;m based in the UK but the web being the web my enquiries have been global. Initially I was skeptical of working with international clients but I&#8217;m already entering my 4th country — outside the British Isles — in as many months, figuratively of course.</p>
<p>I&#8217;m using <a href="http://fre.ag/42q1lcmp" target="_blank">FreeAgent</a> to manage my business — watch out, referral link! It&#8217;s an excellent website for accounts, invoices, time tracking, tax returns, it even has a direct feed to my bank account. Like many of my peers I drafted a contract based on <a href="http://stuffandnonsense.co.uk/projects/contract-killer/" target="_blank">Andy Clarke&#8217;s Killer Contract</a>.</p>
<p>Touch wood my income will remain steady. I like the idea of being transparent in regards to finance and I&#8217;ll do an &#8220;annual report&#8221; if I&#8217;m still afloat next year. I have several projects in mind to generate passive income and a few ambitious start-ups ideas I may bootstrap. Client work will be my bread and butter for a while yet but I want to explore other avenues from day one.</p>
<p>If you want to work with me <a href="/contact/">get in touch</a> and tell me about your project.</p>
<h2>A Good Decision?</h2>
<p>All in all I&#8217;m very happy with the decision I made last year to pack it all up and start a new life. Of course, I miss friends in London and the regular tech meet-ups.</p>
<p>Despite great moments, with the freedom I have now I can&#8217;t see myself ever going back to my old lifestyle. I&#8217;ll never regret moving to London and I would never have been able to go freelance without my experiences there.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbushell.com/2013/05/09/freelance-life/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Origin</title>
		<link>http://dbushell.com/2013/04/30/origin/</link>
		<comments>http://dbushell.com/2013/04/30/origin/#comments</comments>
		<pubDate>Tue, 30 Apr 2013 15:07:08 +0000</pubDate>
		<dc:creator>David Bushell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dbushell.com/?p=8800</guid>
		<description><![CDATA[I&#8217;ve written loads about my flat build process, automation, browser support — in fact, if you follow me on Twitter you&#8217;ll know I can&#8217;t shut up about the Web. What I&#8217;ve been lacking is a canonical resource for my work beyond theoretical writing and live production examples. Despite web standards being open they aren&#8217;t always easy to reverse engineer. [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve written loads about <a href="/2013/04/05/the-flat-build-2/">my flat build process</a>, <a href="/2013/03/12/automation/">automation</a>, <a href="/2013/04/26/on-browser-support/">browser support</a> — in fact, if you follow me on Twitter you&#8217;ll know I can&#8217;t shut up about the Web. What I&#8217;ve been lacking is a canonical resource for my work beyond theoretical writing and live production examples. Despite web standards being open they aren&#8217;t always easy to reverse engineer.</p>
<h2>What is Origin?</h2>
<p>Starting a new project for me used to mean cobbling together and rehashing code from past work. This year I started to consolidate everything into my own personal boilerplate to kick start front-end development.</p>
<p>&#8220;Origin&#8221; is my code name for this on-going project (everything needs a name). It&#8217;s not a behemoth of code like <a href="http://twitter.github.io/bootstrap/" target="_blank">Bootstrap</a> or <a href="http://foundation.zurb.com/" target="_blank">Foundation</a>. It&#8217;s specifically tailored to suit the websites I make. It will never be complete and it will evolve dramatically as my preferences and needs change.</p>
<p>This is not a framework I expect others to use &#8216;as is&#8217; but I decided to make it public because:</p>
<ul>
<li>A lot of people asked kindly</li>
<li>I learn from similar projects by other developers</li>
<li>It will serve as a reference point when discussing particular techniques</li>
</ul>
<p>If you care to poke around the <a href="https://github.com/dbushell/dbushell-Origin" target="_blank">code is on GitHub</a>. Or you can see the <a href="http://dbushell.github.io/dbushell-Origin/" target="_blank">GitHub page</a> for my starting <a href="http://dbushell.github.io/dbushell-Origin/origin.html" target="_blank">pattern library</a>. This doesn&#8217;t include everything I consider a &#8220;best practice&#8221; and a lot of things aren&#8217;t commented. Make of it as you will — just please don&#8217;t include it in a <em>&#8220;10 new resources for developers&#8221;</em> blog post!</p>
<p>If you like the idea of automated builds and need a mature Grunt workflow then give <a href="http://yeoman.io/" target="_blank">Yeoman</a> a test drive. For a BEM-style CSS framework there&#8217;s <a href="https://github.com/csswizardry/inuit.css" target="_blank">Inuit.css</a>. And if you need to prototype something fast, Bootstrap and Foundation have their uses.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbushell.com/2013/04/30/origin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>On Browser Support</title>
		<link>http://dbushell.com/2013/04/26/on-browser-support/</link>
		<comments>http://dbushell.com/2013/04/26/on-browser-support/#comments</comments>
		<pubDate>Fri, 26 Apr 2013 12:37:09 +0000</pubDate>
		<dc:creator>David Bushell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dbushell.com/?p=8611</guid>
		<description><![CDATA[The recently launched jQuery 2.0 leaves behind support for IE6–8. This has lead to some interesting opinions on what browsers we should be supporting. Here&#8217;s my take: Defining support Supporting a browser to me does not mean that a website will be identical in form and function. That is a fool&#8217;s errand leading to an unmanageable mess [...]]]></description>
				<content:encoded><![CDATA[<p>The recently launched <a href="http://blog.jquery.com/2013/04/18/jquery-2-0-released/" target="_blank">jQuery 2.0</a> leaves behind support for IE6–8. This has lead to some interesting opinions on what browsers we should be supporting. Here&#8217;s my take:</p>
<h2>Defining support</h2>
<p>Supporting a browser to me does not mean that a website will be identical in form and function. That is a fool&#8217;s errand leading to an unmanageable mess of polyfills and hacks.</p>
<p>I consider a browser supported if I <strong>actively test</strong> the core content and functionality — integral to the purpose of the website — is accessible. I&#8217;ll also take steps to ensure the quality of design and overall experience is on par with the browser&#8217;s capabilities.</p>
<p>I divide attention proportional to browser usage. I&#8217;m not going to deliver the <em>best possible</em> experience IE7 is capable of but it&#8217;s certainly not going to be broken.</p>
<h2>Deciding where to test</h2>
<p>When I tell people I often support IE7 the common response is &#8220;why?&#8221; — followed by an assertion that browser statistics show IE7 usage is now insignificant enough not to warrant attention. How could you possibly know that? I haven&#8217;t told you which website I&#8217;m building yet!</p>
<p>You see, aggregate statistics are a useful baseline — at least localised, not global — but they become irrelevant if you have data for an existing domain. I look at historical usage numbers, project for the foreseeable future, and only then do I start to decide the appropriate range of browsers to test in. Looking at numbers is not enough to make the final decision.</p>
<p>Other factors to considered include:</p>
<h2>Budget and customers</h2>
<p>Projects are more often than not limited in the funds department. Sometimes it&#8217;s just not financially viable to support and test the long-tail of browsers and devices. This can be a tricky situation in regards to client expectations.</p>
<p>Is the cost of development going to outweigh the loss in revenue that comes from abandoning the less technically astute customers? Imagine a website that sells high value products. A new sale is worth thousands of pounds; suddenly Mr. IE7 user — whom can&#8217;t get past the JavaScript error on the checkout form — begins to look like a good investment after all.</p>
<p>For this reason alone a blanket list of supported browsers shouldn&#8217;t be set in stone. When I wrote about <a href="/2012/03/03/forget-about-browser-support/">browser support</a> last year I said:</p>
<blockquote><p>A traditional browser support list is completely ignorant of a website’s requirements. It wrongly aims for parity across browsers and leads to much wasted time and money.</p></blockquote>
<p>Study requirements in detail. Adjust design and development practices to suit the bottom line. Doing this will tame the client&#8217;s expectations and make them confident with your advice.</p>
<h2>Effort and time</h2>
<p>When the <a href="/2012/03/03/forget-about-browser-support/">previous iteration</a> of dbushell.com launched last March I supported IE6. Yes, that&#8217;s a <em>six</em>. Why? Because the effort required was minimal. Even though the nature of my website means that Internet Explorer as a whole is barely represented in the logs. When I <a href="/2013/02/04/a-new-home/">realigned this year</a> the design was more ambitious and I moved the boundaries up to IE8 and above.</p>
<p>There is no universal scale for effort. It comes down to your ability, but if you decide a website must include the latest trendy 3D parallax effect prior to reading the brief you have no right to rant about the state of browsers or the ignorance of users.</p>
<p>The hard fact is good — appropriate — design for the web is not always glamorous. That means reining in the baseline experience and utilising solid progressive enhancement techniques.</p>
<p>Browser support only becomes a pain if you ignore reality.</p>
<p>That may mean saying &#8220;no&#8221; sometimes to an effect someone has been wowed by on their latest iPad app. And <em>that</em> is probably for the better.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbushell.com/2013/04/26/on-browser-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ember Data and MongoDB</title>
		<link>http://dbushell.com/2013/04/25/ember-data-and-mongodb/</link>
		<comments>http://dbushell.com/2013/04/25/ember-data-and-mongodb/#comments</comments>
		<pubDate>Thu, 25 Apr 2013 18:00:28 +0000</pubDate>
		<dc:creator>David Bushell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dbushell.com/?p=8617</guid>
		<description><![CDATA[Macaque lives! If you&#8217;ve been following my recent blog posts — Part 1: Macaque: A New Project Part 2: Test Driven Development Part 3: Prototyping — you&#8217;ll know I&#8217;m building a to-do app with Node and Ember. Macaque&#8217;s development has reached the point where I can use the app itself for issue and feature tracking. If you want [...]]]></description>
				<content:encoded><![CDATA[<p>Macaque lives! If you&#8217;ve been following my recent blog posts —</p>
<ul>
<li><strong>Part 1:</strong><a href="/2013/04/07/macaque-a-new-project/"> Macaque: A New Project</a></li>
<li><strong>Part 2:</strong> <a href="/2013/04/14/test-driven-development/">Test Driven Development</a></li>
<li><strong>Part 3:</strong> <a href="/2013/04/18/prototyping/">Prototyping</a></li>
</ul>
<p>— you&#8217;ll know I&#8217;m building a to-do app with <a href="http://nodejs.org/" target="_blank">Node</a> and <a href="http://emberjs.com/" target="_blank">Ember</a>. Macaque&#8217;s development has reached the point where I can use the app <em>itself</em> for issue and feature tracking. If you want to see my plans going forward you&#8217;ll have to <a title="Macaque on GitHub" href="https://github.com/dbushell/Macaque" target="_blank">clone the repository</a> and run the app.</p>
<p>I&#8217;ve forked Macaque to use as my personal list app over the next few weeks while I focus on client work. It has a couple of known bugs but nothing that can&#8217;t be fixed with a good ol&#8217; refresh. Hopefully when I jump back into development <a href="https://github.com/emberjs/data" target="_blank">Ember Data</a> will be more mature.</p>
<h2>Ember Data and MongoDB</h2>
<p>Using Ember has been a great learning exercise. After plenty of head scratching and many hours digging around in the source I&#8217;m now feeling comfortable with the core concepts.</p>
<p>If you&#8217;re using MongoDB behind your API here&#8217;s a few things I&#8217;ve learnt:</p>
<h2>Primary IDs</h2>
<p>MongoDB&#8217;s default primary key is an <a href="http://docs.mongodb.org/manual/reference/object-id/" target="_blank">ObjectId</a> in the <code>_id</code> field. Ember Data doesn&#8217;t like the underscore. Initially I was using <a href="http://mongoosejs.com/docs/guide.html#virtuals" target="_blank">Mongoose</a> to add virtual <code>id</code> properties. It&#8217;s actually a lot easier to manage this client-side by extending the <code>RESTAdapter</code>:</p>
<pre data-language="javascript">Macaque.RESTAdapter = DS.RESTAdapter.extend({
    url: 'http://localhost:3000',
    namespace: 'api',

    serializer: DS.RESTSerializer.extend({
        primaryKey: function(type) {
            return '_id';
        }
    })
});

Macaque.Store = DS.Store.extend({
    revision: 12,
    adapter: Macaque.RESTAdapter
});</pre>
<p>In here you can also specify the URL and namespace for the API.</p>
<h2>Serializing the Primary ID</h2>
<p>When the API is called to load a record its ID is serialized in the URL. For example, when a list in Macaque is viewed the <code>RESTAdapter</code> loads data from this endpoint:</p>
<pre>http://localhost:3000/api/lists/5175a9dc67a7a40000000003</pre>
<p>On rare occasions this will fail and you&#8217;ll see the ID has been serialized in this format: <code>5.1755256517945e</code> — note the numerical notation. What&#8217;s going on?</p>
<p>The answer lies within the <a href="https://github.com/emberjs/data/blob/master/packages/ember-data/lib/system/serializer.js" target="_blank">Serializer</a>:</p>
<pre data-language="javascript">/**
    A hook you can use to normalize IDs before adding them to the
    serialized representation.

    Because the store coerces all IDs to strings for consistency,
    this is the opportunity for the serializer to, for example,
    convert numerical IDs back into number form.

    @param {String} id the id from the record
    @returns {any} the serialized representation of the id
  */
  serializeId: function(id) {
    if (isNaN(id)) { return id; }
    return +id;
  },</pre>
<p>If the ID can be converted to a number in JavaScript it will be. ObjectId&#8217;s in MongoDB are a <a href="http://docs.mongodb.org/manual/reference/object-id/" target="_blank">12-byte construct</a>. Usually alpha-numeric and thus &#8220;is not a number&#8221; — but not always. To fix this problem we can extend the <code>RESTSerializer</code> further:</p>
<pre data-language="javascript">Macaque.RESTAdapter = DS.RESTAdapter.extend({
    /* ... */
    serializer: DS.RESTSerializer.extend({
        /* ... */
        serializeId: function(id) {
            return id.toString();
        }
    })
});</pre>
<p class="is-small">(I&#8217;ve removed the previous code for brevity.)</p>
<p>Now our ObjectId values are never inadvertently converted to numbers. With these two changes Ember Data will play nicely with your MongoDB records.</p>
<h2>Many More Things…</h2>
<p>This is something I&#8217;ve been experimenting with so I&#8217;m not convinced it&#8217;s actually the correct approach. I thought it was worth sharing nonetheless because I&#8217;d imagine it&#8217;s a common issue. Anyway, if you have <strong>many-to-many</strong> relationships like I do in Macaque:</p>
<pre data-language="javascript">Macaque.List = DS.Model.extend({
    /* ... */
    tasks: DS.hasMany('Macaque.Task')
});

Macaque.Task = DS.Model.extend({
    /* ... */
    lists: DS.hasMany('Macaque.List')
});</pre>
<p>The API convention is to provide an <code>*_ids</code> array like this <code>GET</code> response for a list record:</p>
<pre data-language="javascript">{
    "list": {
        "_id": "5175786e3351480000000006",
        "task_ids": [
            "517579ab3351480000000008",
            "51757a0b3351480000000009",
            "51757adc335148000000000a"
        ],
        "is_hidden": false,
        "modified": "2013-04-22T18:01:00.959Z",
        "created": "2013-04-22T17:50:38.000Z",
        "name": "Macaque Testing"
    }
    "tasks": {
        /* task data here... */
    }
}</pre>
<p>In this example I can side-load the three task records by including their data in a <code>tasks</code> object in the JSON root. That&#8217;s cool, but problems arise when I edit and save a record in Ember. When I commit the data a <code>PUT</code> request is sent to the API like this:</p>
<pre data-language="javascript">{
    "list": {
        "_id": "5175786e3351480000000006",
        "is_hidden": false,
        "modified": "2013-04-22T18:01:00.959Z",
        "created": "2013-04-22T17:50:38.000Z",
        "name": "Macaque Testing"
    }
}</pre>
<p>Note the child task IDs are never sent back to the server.</p>
<p>From what I understand the <code>hasMany</code> relationships are only serialised in the JSON if you&#8217;re specifically embedding all data in every request. You can tell Ember Data to do this…</p>
<pre data-language="javascript">Macaque.RESTAdapter.map('Macaque.Lists', {
    'tasks': { embedded: 'always' }
});
Macaque.RESTAdapter.map('Macaque.Tasks', {
    'lists': { embedded: 'always' }
});</pre>
<p>…but it&#8217;s not very practical; that&#8217;s a lot of data where an array of IDs would suffice. I&#8217;ve found a workaround is to extend the <code>RESTSerializer</code> — once again — to include the ID array:</p>
<pre data-language="javascript">Macaque.RESTAdapter = DS.RESTAdapter.extend({
    /* ... */
    serializer: DS.RESTSerializer.extend({
        /* ... */
        addHasMany: function(hash, record, key, relationship)
        {
            if (/_ids$/.test(key)) {
                hash[key] = [];
                record.get(this.pluralize(key.replace(/_ids$/, ''))).forEach(function(item) {
                    hash[key].push(item.get('id'));
                });
            }
            return hash;
        }
    })
});</pre>
<p>This will now include the <code>hasMany</code> relationships in data sent back to the API.</p>
<p>When I send a new task to the server — including <code>list_ids</code> — I can then update the corresponding list(s) relationships in the database. The server returns the new task with its <code>_id</code> which Ember can confirm. Once the ID arrives I can reload the relevant lists to ensure their <code>task_ids</code> are up-to-date and finally make the task visible.</p>
<p>I&#8217;m not entirely convinced this technique is the best way to maintain many-to-many relationships. I haven&#8217;t tested the <code>{ embedded: 'always' }</code> technique so I can&#8217;t confirm Ember Data actually handles this correctly. Either way it feels overkill.</p>
<p>Am I doing something wrong, or do you know a better way? <a href="https://twitter.com/dbushell" target="_blank">Give me a shout on Twitter</a> or comment on <a href="https://news.ycombinator.com/item?id=5608851" target="_blank">Hacker News</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbushell.com/2013/04/25/ember-data-and-mongodb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prototyping</title>
		<link>http://dbushell.com/2013/04/18/prototyping/</link>
		<comments>http://dbushell.com/2013/04/18/prototyping/#comments</comments>
		<pubDate>Thu, 18 Apr 2013 19:45:37 +0000</pubDate>
		<dc:creator>David Bushell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dbushell.com/?p=8533</guid>
		<description><![CDATA[A couple of weeks ago I embarked upon a new side quest: make a list app and use as much JavaScript in the stack as possible. Fighting adversity, I&#8217;ve made progress: Twitter Bootstrap is a great UI toolkit for prototypes. Don&#8217;t let it seduce you, my underlying code ain&#8217;t pretty! Learning Curve After the excitement of [...]]]></description>
				<content:encoded><![CDATA[<p>A <a title="Macaque: A New Project" href="/2013/04/07/macaque-a-new-project/">couple of weeks ago</a> I embarked upon a new side quest: make a list app and use as much JavaScript in the stack as possible. Fighting adversity, I&#8217;ve made progress:</p>
<p class="post-image"><a href="http://dbushell.com/wp-content/uploads/2013/04/screenshot.png"><img alt="Macaque app screenshot" src="http://dbushell.com/wp-content/uploads/2013/04/screenshot.png" /></a></p>
<p class="is-small"><a href="http://twitter.github.io/bootstrap/" target="_blank">Twitter Bootstrap</a> is a great UI toolkit for prototypes. Don&#8217;t let it seduce you, my underlying code ain&#8217;t pretty!</p>
<h2>Learning Curve</h2>
<p>After the excitement of last weekend&#8217;s <a title="Test Driven Development" href="/2013/04/14/test-driven-development/">test driven development</a> phase I hit hard times and considered throwing in the towel once or twice. I have very little experience with MVC frameworks. In fact, with the exception of a terrible two days flirting with Backbone, I&#8217;ve have none.</p>
<p>What exists in the <a href="http://emberjs.com/guides/" target="_blank">Ember Guides</a> is very good but far from complete as you&#8217;d expect from such a new technology. <a href="https://github.com/emberjs/data" target="_blank">Ember Data</a> is still under development so little documentation exists. For someone who has &#8216;designer&#8217; written on his business cards; this is <em>very</em> slow learning. StackOverflow has rescued me many times. <a href="http://emberwatch.com/" target="_blank">Ember Watch</a> is also an excellent resource. Progress may be glacial, but I&#8217;m moving forward. <strong>Macaque</strong> is far from complete but you see the <a href="https://github.com/dbushell/Macaque" target="_blank">code on GitHub</a>.</p>
<h2>Experimental</h2>
<p>Although I&#8217;m kind of ad-libbing this entire thing, I&#8217;m keen to tie in several project methodologies. I started with a half-hearted attempt at agile user stories (<em>user can use to-do app</em>). Unsurprisingly, it&#8217;s transpired that development is now meandering through whatever aspects of Ember I happen to figure out. This evolutionary approach isn&#8217;t quite what I had in mind. Once I feel more comfortable with Ember I&#8217;ll take a step back and refocus the project scope.</p>
<p>This process is very good for <a href="/2012/09/17/agile-website-design-and-development/">agile design</a>. Right now I&#8217;m letting development lead the experience and making design decisions as and when required. That&#8217;s not much right now, which is a good thing. I&#8217;m not over committing to style or interaction that could prove impossible later (or ill-advised). It may be a simple concept but designing whilst actually <em>using</em> the app is a lot better than designing from imagination alone.</p>
<p><strong>Update: Part 4 —</strong> <a href="/2013/04/25/ember-data-and-mongodb/">Ember Data and MongoDB</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dbushell.com/2013/04/18/prototyping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Test Driven Development</title>
		<link>http://dbushell.com/2013/04/14/test-driven-development/</link>
		<comments>http://dbushell.com/2013/04/14/test-driven-development/#comments</comments>
		<pubDate>Sun, 14 Apr 2013 19:36:37 +0000</pubDate>
		<dc:creator>David Bushell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dbushell.com/?p=8445</guid>
		<description><![CDATA[I&#8217;ve been hacking away at my side project Macaque today. It&#8217;s quickly becoming the world&#8217;s most over-engineered to-do app. At the moment it&#8217;s categorising primates: Isn&#8217;t it beautiful? As you can see, my big ideas for Macaque focus on design but I am building it end-to-end. For the supporting back-end I&#8217;ve spent the weekend writing and testing an API. I [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been hacking away at my side project <a href="/2013/04/07/macaque-a-new-project/">Macaque</a> today. It&#8217;s quickly becoming the world&#8217;s most over-engineered to-do app. At the moment it&#8217;s categorising primates:</p>
<p class="post-image"><img alt="macaque-index" src="http://dbushell.com/wp-content/uploads/2013/04/macaque-index.png" /></p>
<p>Isn&#8217;t it beautiful?</p>
<p>As you can see, my big ideas for Macaque focus on design but I am building it end-to-end. For the supporting back-end I&#8217;ve spent the weekend writing and testing an API. I could have thrown together a diabolical concoction of PHP and MySQL and been done with it. However, since I genuinely plan to use this app, I&#8217;ve opted for an ultra-trendy Node solution.</p>
<h2>Testing an API</h2>
<p>My app has a very simple RESTful API that interfaces with a <a href="http://www.mongodb.org/" target="_blank">Mongo</a> database. My API can retrieve, edit, and add items to one or more lists. That&#8217;s innovation right there. You can follow my <a href="https://github.com/dbushell/Macaque" target="_blank">code progress on GitHub</a>.</p>
<p>In fairness, It&#8217;s probably the least impressive API one could possibly development but that doesn&#8217;t make it any easier to test. Even if the front-end wasn&#8217;t lacking in functionality at this stage it would be a tedious way to find bugs. Inspired by my old office mates at <a href="http://www.uvd.co.uk/blog/a-night-of-tdd-and-full-stack-bdd-review/" target="_blank">UVd</a> and <a href="http://www.browserlondon.com/blog/2013/03/tdd-and-bdd/" target="_blank">Browser</a>, I&#8217;ve spent some time implementing <strong>test driven development</strong> into my workflow.</p>
<p>For this I&#8217;ve used <a href="http://visionmedia.github.io/mocha/" target="_blank">Mocha</a> to write a series of tests for my API. Each test calls the API and then checks the returning data. For example, to make sure <code>/api/lists</code> is returning an array:</p>
<pre data-language="javascript">describe('Lists', function() {
    it('should return an array of lists', function(done) {
        macaqueAPI('/api/lists', function(data) {
            var json = JSON.parse(data);
            assert.equal(true, Array.isArray(json.lists));
            assert.equal(false, isNaN(json.lists.length));
            done();
        });
   });
});</pre>
<p>When I run all tests from the command line:</p>
<p class="post-image"><img alt="Mocha tests" src="http://dbushell.com/wp-content/uploads/2013/04/macaque-mocha-tests.png" /></p>
<p>Pretty cool, right?</p>
<p>This effort has already paid dividends when I came to refactor my API to make use of <a href="http://mongoosejs.com/" target="_blank">Mongoose</a> — a library that provides schema, data validation, and generally easier coding. I had to rewrite much of my code but running the tests again gave me instant confidence it was correct.</p>
<h2>Onwards</h2>
<p>I&#8217;ve already got <a href="http://emberjs.com/" target="_blank">Ember</a> working with the API to output list and task templates. It&#8217;s now time to focus on design of the front-end user interface.</p>
<p>Following my experience with Mocha I&#8217;m hooked on automated testing and I look forward to bringing it into the browser with other frameworks.</p>
<p>Stay tuned for prettier pictures.</p>
<p><strong>Update: Part 3 —</strong> <a href="/2013/04/18/prototyping/">Prototyping</a><br />
<strong>Update: Part 4 —</strong> <a href="/2013/04/25/ember-data-and-mongodb/">Ember Data and MongoDB</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dbushell.com/2013/04/14/test-driven-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Macaque: A New Project</title>
		<link>http://dbushell.com/2013/04/07/macaque-a-new-project/</link>
		<comments>http://dbushell.com/2013/04/07/macaque-a-new-project/#comments</comments>
		<pubDate>Sun, 07 Apr 2013 21:35:39 +0000</pubDate>
		<dc:creator>David Bushell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dbushell.com/?p=8361</guid>
		<description><![CDATA[Today I started a new project. Macaque will be a personal to-do or list app. Sounds simple, right? Unlike my other side projects I&#8217;m coding and designing in public from day one. This project exists because: I want to learn more Node and Ember I&#8217;ve failed to find a list app I like (oh lord, please don&#8217;t suggest [...]]]></description>
				<content:encoded><![CDATA[<p>Today I started a new project. <strong>Macaque</strong> will be a personal to-do or list app. Sounds simple, right? Unlike my other side projects I&#8217;m coding and designing in public from day one.</p>
<p>This project exists because:</p>
<ul>
<li>I want to learn more <a href="http://nodejs.org/" target="_blank">Node</a> and <a href="http://emberjs.com/" target="_blank">Ember</a></li>
<li>I&#8217;ve failed to find a list app I like (oh lord, please don&#8217;t suggest one)</li>
<li>I&#8217;d like to <em>own</em> my data and &#8216;reinvent&#8217; the list app experience (for myself)</li>
</ul>
<p>If you care you can follow my <a href="https://github.com/dbushell/Macaque" target="_blank">progress on GitHub</a>. I&#8217;m keeping the features stupidly simple because there is already so much to consider.</p>
<h2>Starting point</h2>
<p>I&#8217;ve played with Node before but I&#8217;m starting Ember development with a blank slate. This weekend I&#8217;ve been casually introducing myself.</p>
<p>While I dived into Ember routes and templates I threw together a quick <a href="http://expressjs.com/" target="_blank">Express</a> app to serve fake API data. I feel comfortable with that now. I can see a list of tasks! The next step is add, edit, and delete functionality. That means going back to data storage and a real API. I want to do this quickly because it&#8217;s not my main interest.</p>
<h2>Moving forward</h2>
<p>Once the API is ready I&#8217;ll return to Ember and implement the functionality. For UI design I&#8217;ll start with either <a href="http://twitter.github.io/bootstrap/" target="_blank">Bootstrap</a> or <a href="http://foundation.zurb.com/" target="_blank">Foundation</a> so it&#8217;s not ugly. I&#8217;ll be designing the final interface as I learn Ember and will eventually throw out the framework and rebuild the HTML &amp; CSS from scratch. The interaction design I&#8217;m envisioning will require advanced Ember concepts (I expect) so it will be useful to having a basic version in place first.</p>
<p>I plan to publish everything under the MIT license prior to implementing my advanced design. I think it will be a helpful review project for future beginners.</p>
<p>And if I get that far? I&#8217;m plotting the heinous crime of parcelling the website in a native Android wrapper and installing it on my phone.</p>
<p>Words cannot express how happy that would make me.</p>
<p>Before I continue with any of this I need an icon! If you see me tweeting a poorly traced Macaque face, this is why. If you too are interested in Ember, aside from the oficial docs, Robin Ward (Evil Trout) has a great <a href="http://eviltrout.com/2013/02/27/adding-to-discourse-part-1.html" target="_blank">Ember series</a> on his blog.</p>
<p><strong>Update: Part 2 —</strong> <a href="/2013/04/14/test-driven-development/">Test Driven Development</a><br />
<strong>Update: Part 3 —</strong> <a href="/2013/04/18/prototyping/">Prototyping</a><br />
<strong>Update: Part 4 —</strong> <a href="/2013/04/25/ember-data-and-mongodb/">Ember Data and MongoDB</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dbushell.com/2013/04/07/macaque-a-new-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Flat Build (2)</title>
		<link>http://dbushell.com/2013/04/05/the-flat-build-2/</link>
		<comments>http://dbushell.com/2013/04/05/the-flat-build-2/#comments</comments>
		<pubDate>Fri, 05 Apr 2013 10:26:18 +0000</pubDate>
		<dc:creator>David Bushell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dbushell.com/?p=8223</guid>
		<description><![CDATA[My article The Flat Build was a slow burner but it has picked up steam recently and for the first time in like, forever, I&#8217;m building a pre-designed* website without having design influence. This has proven to be a good opportunity to refine and expand upon my flat build workflow (again). I&#8217;m aware I&#8217;m reinventing more [...]]]></description>
				<content:encoded><![CDATA[<p>My article <a href="/2013/03/18/the-flat-build/">The Flat Build</a> was a slow burner but it has picked up steam recently and for the first time in like, forever, I&#8217;m building a pre-designed* website without having design influence. This has proven to be a good opportunity to refine and expand upon my flat build workflow (again).</p>
<p>I&#8217;m aware I&#8217;m reinventing more than a few wheels here. This project has always been about starting from the ground up and questioning every choice.</p>
<p class="is-small">* Yeah, I&#8217;m a big advocate for agile &#8220;decide in the browser&#8221; web design/dev, but I have to admit that a beautifully maintained PSD deliverable still feels like Christmas.</p>
<h2>Boilerplate</h2>
<p>I&#8217;ve always maintained a personal set of HTML &amp; CSS files to use as a starting point for any build. Mostly good practices, general preferences, and stuff I forget like the favicon.</p>
<p class="post-image"><img style="max-width: 30em;" alt="Icon Slate favicon app" src="http://dbushell.com/wp-content/uploads/2013/04/iconslateapp.png" /></p>
<p>This practice has never actually helped me <em>remember</em> the favicon — you have to love boilerplate deployment — but after catching up with <a href="http://css-tricks.com/video-screencasts/122-the-state-of-favicons/" target="_blank">Chris Coyier&#8217;s screencast</a> I have a new found love. I&#8217;m currently writing the favicon-first manifesto…</p>
<h2>Repository</h2>
<p>I use Git as source control for everything. This includes my boilerplate which I can evolve and fork for new projects. Starting a new build requires these steps:</p>
<ol>
<li>Initialise a new Git repo</li>
<li>Merge in my boilerplate code</li>
<li>Run <code>npm install</code> to pull in dependencies (basically <a href="http://gruntjs.com/" target="_blank">Grunt</a> + tasks)</li>
</ol>
<p><a href="http://www.sublimetext.com/2" target="_blank">Sublime Text 2</a> and <a href="http://www.iterm2.com/" target="_blank">iTerm</a> (with<a href="https://github.com/robbyrussell/oh-my-zsh" target="_blank"> oh-my-zsh</a>) are my apps of choice for code management.</p>
<p class="post-image"><img style="max-width: 40em;" alt="Sublime and iTerm" src="http://dbushell.com/wp-content/uploads/2013/04/sublimeproject.png" /></p>
<p class="is-small">And yes, I work on the master branch and name my devices after monkeys.</p>
<p>As you can see my project directory structure looks like this:</p>
<ul>
<li><code>build/</code></li>
<li><code>src/</code></li>
<li><code>tasks/</code></li>
<li><code>templates/</code></li>
<li><code>Gruntfile.js</code></li>
<li><code>package.json</code></li>
<li><code>README.md</code></li>
</ul>
<p>The <code>build</code> directory is generated by Grunt and never committed to Git. It contains the final static website with no outside dependencies. I can view it in the browser, archive and email to a client, toss on a server, or just delete and rebuild it entirely for a laugh (that novelty wears off).</p>
<p>The <code>src</code> directory contains the actual editable source and original assets; Sass, JavaScript, SVG, web fonts etc. The <code>templates</code> directory contains HTML (I should probably move this into <code>src</code> for consistency). My <a href="https://gist.github.com/dbushell/5317948" target="_blank">HTML Grunt task</a> — new and improved* — lets me separate HTML includes and reference relative assets or paths. All without server-side scripting.</p>
<p class="is-small">* use at your own risk.</p>
<p>The basic principle here is to keep a <strong>single source</strong> for all working assets. If that isn&#8217;t the final output — e.g. Sass or un-minified JavaScript — the output should get compiled automatically. Similarly, I don&#8217;t want to manually maintain PNG fallbacks for vector graphics if they can be built from source. The whole set up is complex but the act of building is simplified.</p>
<p>The complete set of build tasks can be quite slow so I need to build individual components as and when they are modified.</p>
<h2>Who watches the watchmen?</h2>
<p>I&#8217;ve been using <a href="http://compass-style.org/" target="_blank">Compass</a> for a long time to generate CSS. With pre-processors you get a nice command line programme to watch for changes and automatically generate plain CSS output. This alleviates the burden that an extra step adds.</p>
<p>With my new practice of separation between source and build I need a more powerful watcher. <a href="https://github.com/gruntjs/grunt-contrib-watch" target="_blank">Grunt watch</a> comes to the rescue. For each requirement I instruct it to watch a set of files and then perform a specific task. HTML is edited? Rebuild it. CSS changes? Recompile it. SVGs are modified? Optimise and create raster fallbacks (OK, <a href="https://twitter.com/dbushell/status/318733510674350081/" target="_blank">I haven&#8217;t perfected that yet</a>).</p>
<p>Whenever I&#8217;m working on a project I just run <code>grunt watch</code> and let it go.</p>
<h2>Next step</h2>
<p>Like I said, none of this is particular ground breaking but I&#8217;m learning a huge amount by starting from scratch. I could jump straight into an existing solution like <a href="http://yeoman.io/" target="_blank">Yeoman</a> but I&#8217;d never really understand the &#8220;why&#8221; behind the process. My quest is <a href="/2013/03/12/automation/">automation</a> and I&#8217;m already making life easier. Even with the less than optimal set of tasks I&#8217;ve hacked together.</p>
<p>I&#8217;ve written a lot about <strong>facilitating</strong> the build process but not the actual practice of writing HTML, CSS, and JavaScript itself. The most time consuming thing of all. I&#8217;ll follow up on that soon, for now read my <a href="/2013/01/01/five-tips-for-responsive-builds/">5 Tips for Responsive Builds</a> and be sure to read Dave Rupert&#8217;s excellent article on <a href="http://daverupert.com/2013/04/responsive-deliverables/" target="_blank">Responsive Deliverables</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbushell.com/2013/04/05/the-flat-build-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>On Responsive Layout and Grids</title>
		<link>http://dbushell.com/2013/03/19/on-responsive-layout-and-grids/</link>
		<comments>http://dbushell.com/2013/03/19/on-responsive-layout-and-grids/#comments</comments>
		<pubDate>Tue, 19 Mar 2013 11:33:46 +0000</pubDate>
		<dc:creator>David Bushell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dbushell.com/?p=8019</guid>
		<description><![CDATA[I often get asked which responsive grid system I use. This is a very frustrating question because it implies a requirement where I have none. With the myriad solutions presented I can&#8217;t blame people for thinking they have a choice to make. This article is my response to that question. Anatomy of a grid system [...]]]></description>
				<content:encoded><![CDATA[<p>I often get asked which responsive grid system I use. This is a very frustrating question because it implies a requirement where I have none. With the myriad solutions presented I can&#8217;t blame people for thinking they have a choice to make.</p>
<p>This article is my response to that question.</p>
<h2>Anatomy of a grid system</h2>
<p>Responsive grid systems can be broken into two main parts:</p>
<ol>
<li>A CSS construct for the basic grid cell/unit</li>
<li>A catch-all methodology to cover generic column layout</li>
</ol>
<p>Most systems I see feature a largely trivial decision around part #1 and a load of nonsense for part #2 — in my opinion. I don&#8217;t mean to insult those who attempt this. Many smart minds have produced very interesting results worth studying. I call it nonsense because overcomplicating the problem will always produce crazy complex solutions. I believe this comes down to a desire to abstract code too far.</p>
<p>This is how I handle responsive layout:</p>
<h2>Part 1 — the basic unit</h2>
<p>There are numerous ways to achieve this. The principle is to align elements as columns with an even gutter between them. Here&#8217;s a five-column example:</p>
<p class="post-image"><img alt="responsive grid" src="http://dbushell.com/wp-content/uploads/2013/03/basic-grid.svg" /></p>
<p>I&#8217;d be worried if that surprised you but illustrations make a long article look nice. From <a href="/2012/03/27/introducing-shiro/">experimentation last year</a> I&#8217;ve been using this CSS construct ever since:</p>
<pre data-language="css">.grid {
    @include clearfix;
    margin: 0 -1.5em;
}
.grid-unit {
    box-sizing: border-box;
    display: block;
    float: left;
    padding: 0 1.5em;
    width: 100%;
}
.layout .grid-unit {
    width: 20%;
}</pre>
<p>The <code>.grid</code> class acts as a container for grid units. The unit padding and negative container margins make for very tidy alignment — I&#8217;ll come back to <code>.layout</code> later.</p>
<p>Units are outlined in black in the diagram below:</p>
<p class="post-image"><img alt="responsive grid with margin and padding visible" src="http://dbushell.com/wp-content/uploads/2013/03/basic-grid-unit.svg" /></p>
<p>You can achieve the same thing with inline blocks or table-cell display. I called this choice trivial. It&#8217;s not <em>entirely</em> inconsequential. You need to consider browser support and it will affect how you style content inside the grid.</p>
<p>Personally I like to separate these layout elements with an extra <code>div</code> to avoid conflicts with visible content styles. You may gasp in horror at the thought of extra markup — I&#8217;ll be in the pub Friday evening by 6pm. That&#8217;s literally the only significant consequence.</p>
<p>When support for <a href="http://www.w3.org/TR/css3-flexbox/" target="_blank">CSS Flexbox</a> hits critical mass I&#8217;ll likely transition towards that for grid units. It has a magic <code>order</code> property that will solve responsive layout <em>forever</em>.</p>
<h2>Part 2 — responsive layout</h2>
<p>This is the meat and potatoes of a responsive grid system and the reason I ultimately reject many of them. The ones that try to offer pre-defined classes for every possible column arrangement are a lost cause.</p>
<p>In my opinion there&#8217;s a fundamentally flawed logic in trying to write a generic catch-all solution. You&#8217;re always going to end up with hundreds of unnecessary variations. If you use classes it&#8217;s going to look hideously confusing. If you <em>don&#8217;t</em> use classes it&#8217;s going to look horrendously perplexing.</p>
<p>I write responsive layout CSS on a per-module basis as-and-when required. Let&#8217;s say I have four feature boxes on my home page:</p>
<p class="post-image"><img alt="responsive grid layout" src="http://dbushell.com/wp-content/uploads/2013/03/grid-layout.svg" /></p>
<p>By default they&#8217;re stacked vertically (I may progressively enhance to a fancy carousel but that&#8217;s beside the point). On a medium sized viewport I want them two-by-two. Widest breakpoint; one row, four columns.</p>
<p>My HTML is as you&#8217;d expect, ignoring possible semantic choices like <code>section</code> or <code>article</code> elements. I may not even need an extra <code>div</code> to style my features:</p>
<pre data-language="html">&lt;div class="grid home-features"&gt;
    &lt;div class="grid-unit"&gt;&lt;!-- feature 1 --&gt;&lt;/div&gt;
    &lt;div class="grid-unit"&gt;&lt;!-- feature 2 --&gt;&lt;/div&gt;
    &lt;div class="grid-unit"&gt;&lt;!-- feature 3 --&gt;&lt;/div&gt;
    &lt;div class="grid-unit"&gt;&lt;!-- feature 4 --&gt;&lt;/div&gt;
&lt;/div&gt;</pre>
<p>The additional CSS I need is minimal:</p>
<pre data-language="css">@media screen and (min-width: 40em) {
    .home-features .grid-unit {
        width: 50%;
    }
}
@media screen and (min-width: 60em) {
    .home-features .grid-unit {
        width: 25%;
    }
}</pre>
<p>In practice it&#8217;s a bit more complicated because I&#8217;m ignoring vertical spacing here but my basic principle still applies: <strong>avoid defining layout until I need it</strong>.</p>
<p class="is-small">(In practice I actually use a lot of CSS preprocessor techniques to avoid multiple classes.)</p>
<h2>Abstraction</h2>
<p>This doesn&#8217;t mean I can&#8217;t abstract and reuse common layouts. If my features module is used beyond the home page I just apply CSS with a non page-specific class name.</p>
<p>Say I reuse the features module on the &#8220;blog&#8221; page but it&#8217;s now nested inside another layout with half the available width? I simply abstract the common visual styles with a <code>.features</code> class and apply different layout and breakpoints using <code>.home-features</code> and now <code>.blog-features</code> (or a hook higher up in the DOM).</p>
<p>You can&#8217;t define good responsive breakpoints until you know content and location. That&#8217;s another reason to avoid pre-defined systems.</p>
<h2>Job done</h2>
<p>I&#8217;ve build websites large and small with this philosophy and I really don&#8217;t see a situation where it needs to be any more complicated. I love modular CSS as much as the next person but there&#8217;s a point where it becomes an abstraction too far. Don&#8217;t solve a problem until it exists. From my experience, trying to find a pre-defined system for every permutation of nested grids is a fool&#8217;s errand.</p>
<h2>Design vs code</h2>
<p>Finally, though a website is designed on a grid doesn&#8217;t me we have to replicate it entirely with a single code system. In my <a href="/2012/06/17/passenger-focus-responsive-web-design-case-study/" target="_blank">Passenger Focus case study</a> I highlight the areas where my technique above kicks in (grid units are outlined in blue):</p>
<p class="post-image"><a href="http://dbushell.com/wp-content/uploads/2012/06/pf-grid.png"><img alt="Passenger Focus website grid design" src="http://dbushell.com/wp-content/uploads/2012/06/pf-grid.png" /></a></p>
<p>The header was designed on the grid but bespoke layout CSS was easier to manage.</p>
<p>So for those who often enquire about my responsive grid &#8220;solution&#8221; — it&#8217;s about 10 lines of code. Not a problem that keeps me up at night.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbushell.com/2013/03/19/on-responsive-layout-and-grids/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
