Things Well Made

Craftsmanship excellence and the design of beautiful things

Thing well made: insanely simple background tasks with delayed_job

January18

If you’re doing web development of any substance the first thing you’ll hit is how to avoid users having to wait for things that take ‘a long time’. Like sending emails.

A naive implementation for reset password could be:

  1. User requests ‘place order’
  2. Server processes request and sends order details to user’s email account
  3. User is presented message to this effect

Thing is, (2) could take ages (particularly if you’re using free SMTP remailer services like Gmail where it typically takes 2-4s by design).

What would be nicer is something like this:

  1. User requests ‘place order’
  2. Server creates a task to do this in the background
  3. Server immediately responds with a ‘order details will be sent very shortly’
  4. User receives order details more or less the same time as in first scenario

Because (3) is shown to the user faster, they can get on and do other things, and also your server’s request processor isn’t held up.

This seems obvious but its amazing how hard this queuing / background processing is to get right (e.g. if its in the background, how do you make sure the context is set up when its run later, etc). I think for a large number of cases, the Ruby on Rails gem ‘delayed_job’ does an incredible job. Check this out:

Original code:

Order.place_order(order_request)

or 100% equivalently in ruby:

Order.send(:place_order, order_request)

With delayed_job, here’s the new code that is run in the background:

Order.send_later( :place_order, order_request )

delayed_job adds this feature to every class in Rails! So sending email is the same:

Mailer.send_later( :deliver_order_confirmation, self )

It’s incredibly well designed because it is so simple. A thing well made indeed. Other parts are simple as well:

  • delayed_job only needs a single server but supports more than one very easily (just create new instances)
  • As its a plugin adding support to your Rails system is a single command (script/plugin install delayed_job).

Notes

Right now delayed_job is heavily forked on github — there seem to be about 20+ variations. The one that most seem to use is collectiveidea’s branch:

Delated_job or DJ encapsulates the common pattern of asynchronously executing longer tasks in the background.

via collectiveidea’s delayed_job at master – GitHub.

… although for automated testing there is a great feature in hashrocket’s variation that allows you to force the background job to be, well, not background any more with a ’synchrony’ flag. So I’ve used a combination of both. I’m sure this will settle down the coming months.

A thing well made: the Audience A1026 voice processor (why Google Nexus One call quality is so good)

January9

Earlier this week Google launched the Nexus One by HTC with Android 2.1. At Google were  given one of these phones for Christmas — awesome screen and slimline form aside, one of the outstanding-yet-unsung features of the phone is its amazing call quality.

This phone [Google Nexus One]? You gotta try it. Leave the apps alone and try making a voice call with it. You won’t believe it. The Nexus One’s rock-solid voice quality may bring phone sex back to smartphone users.

via The magical chip that delivers Nexus One’s call quality | VentureBeat.

Here’s a uselessly small illustration of how it works:

The Audience processor has 2 mics

Sorry that’s a bit small to see. I’ll try and update later with a bigger pic. One of the reasons A1026 is clever because it uses 2 microphones and in essence uses one to sample background noise and ’subtract’ it from the sound being sent. Net result — you can really hear people better in noisy environments, its amazing.

View online demos — they could well be faked up but they convey reality very well (it’d be great if they allowed you to embed the demos in other pages.. but sadly its just one big fat Flash file).

Truly a thing of beauty.

A thing well made: Dyson Air Multiplier™ fan

January9
I saw one of these gorgeous fans at the Conran shop in Marylebone High St. Its beautifully designed — so simple, and its just plain weird that there aren’t any blades in the air hole.
Its a thing well made for 2 reasons. Firstly, it does its job amazingly well:
Normal fans: lots of buffetting of air:
Choppy Air Flow
Whereas the Air Multiplier creates a continuous stream of wind. It really feels like wind.
Smooth Air Flow

via Dyson Air Multiplier™ fan | Dyson.co.uk.

Now at £200-odd its not the cheapest fan in the world, but then, things well made often aren’t.

Secondly, its beautiful to look at. Very simple, clean design. Because it has no fan blades, and no blade cage, it is visually as simple as a fan could be.

Dyson, you’ve done it again: a Thing Well Made.

What Beautiful HTML Code Looks Like | CSS-Tricks

January5

This is what this site is all about: excellence in craftsmanship. Things well made, like HTML pages:

It gets me to thinking, what makes beautiful code? In HTML, it comes down to craftsmanship. Let’s take a look at some markup written they way markup should be written and see how beautiful it can be.

via What Beautiful HTML Code Looks Like | CSS-Tricks.

Newer Entries »

I’ve always appreciated things that have had love, care and attention put into them. Where its obvious that the thing that was created was created for reasons above purely commercial gain.

Don McGlashan says it best in ‘Thing Well Made’ by the Mutton Birds:

To make a thing like that you’d need to know what you were about.
You’d have to know where you were going and go there in a straight line.
And everything else you’d have to shut right out.
Can you see the man who made that?
Can you see him putting it down and standing back?
Can you see the moment when he said “That’s it. That’s perfect.”?
At a time like that you wouldn’t care about your job,
Or your mortgage, or the fight you had with your wife.
‘Cause when a man holds a thing well made,
There’s connection,
There’s completeness when a man holds a thing well made.

Watch live recording of A Thing Well Made by the Mutton Birds

This site is dedicated to this song and to all those people in the world who create Things Well Made.



 

You need to log in to vote

The blog owner requires users to be logged in to be able to vote for this post.

Alternatively, if you do not have an account yet you can create one here.

Powered by Vote It Up