Simple patterns: PHP to JavaScript

You can pass data between the client and server in a number of ways. I like to mirror data structures between my server and client, so that I have the same basic data model available in both realms. There are a few ways to do this, including: Calling an API that returns JSON (or JSONP) Calling an API that returns some UI, which can include some JSON Getting an entire page that includes your data model in JSON Sending a client data is trivial in most dynamic languages, and PHP is no different. You return a response body with the result of a json_encode and your data model. The technique works just as well in APIs as it does in standard HTML templates: ...

June 25, 2013 · Bruce Alderson

Five things to love about PHP

PHP is a great language. It follows a long lineage of C-based syntaxes, mirroring much of the C standard library. It performs well, is trivial to deploy, and has been stable for many years. And, it’s almost universally hated. While many people look down on PHP, it’s worth considering where it shines compared to other languages. I find that in many uses, PHP provides a great set of features and elegance. Not only is it competent, but there are places where it is truly a great little tool. ...

June 17, 2013 · Bruce Alderson

HTTP, GET, and fuzzy semantics

A developer asked me a seemingly obvious question today: I have an API GET request that requires a JSON body. Is that okay? It’s a good question too. It turns out the answer isn’t as simple as it should be. On principle the answer is, “No, it’s not cool”. A GET is an idempotent request for a resource. You don’t request a resource with a resource (what would that mean?), you request it with a resource identifier. The HTTP spec, however, is unclear on the subject and does not explicitly disallow it (it probably should). ...

January 26, 2013 · Bruce Alderson

Summer design fragments

I’ve been busy working on visual design bits for work projects this summer. My method is simple: Sketches and storyboards Static mockups (HTML/CSS, some Javascript) Live mockups (to test integration and interactions) Uncovering what a feature means is fundamental to the method. It exposes the nouns and verbs of the problem, and hints at the useful metaphors. The freeform nature of sketching and developing storyboards based on this language helps me focus on figuring out what the things mean, as well as finding their shape and rhythm. I end up working on several different approaches before it’s obvious which ones are workable for the client and product. ...

September 30, 2012 · Bruce Alderson

The myth of uphill

Friction works against you. It exceeds your ability to progress. It deflates you, stripping your motivation. It’s the hill you see before starting a difficult project. It’s the gravity that pulls you away when interest wanes. I’m starting a small project for a client today. It’s a simple set of improvements to something I built for them last year, using a toolkit I wouldn’t normally use (but one that fit their uses well enough). I had forgotten a lot about the toolkit when quoting on the work, and by the time I remember it’s clear that there are challenges ahead of me. ...

September 3, 2012 · Bruce Alderson