Thursday, August 02, 2007

Data mismatches

Over the years, each of the traditional system tiers - database, web server, browser - has grown more powerful, reliable and manageable.

The problem is, they still don't work with each other well!

I still haven't seen an elegant way to create object oriented code from queries of relational tables (although LINQ comes closest).

And using objects to manage semi-structured, hierarchical HTML doesn't work nicely either - that's why the DOM is so ugly.

Finally, placing (X)HTML neatly in a relational database is very awkward, although that hasn't stopped vendors from attempting it.

Different forms of data

That's because they all use different approaches to model data - table, object, and document.

Each approach has many advantages, each requires a different technical skill and personality type to use, and each works best in different circumstances. Unfortunately, they don't work together particularly well.

Can this last?

At the moment there are a few creaks, but no cracks. The creaks are
  • The success of scripting languages like PHP in managing documents, rather than formal object oriented code
  • Buzz around REST, which uses URLs and HTTP to store (and even edit) data, hiding the underlying relational database
  • Relational databases increasingly outputting XML, rather than proprietary data

Another approach - REST, XQuery

It is now (just) possible to use the document approach throughout every tier. It makes code enormously easy to write and maintain, and it fits perfectly into the web.

You wouldn't want to do this for data-intensive applications, such as handling financial market data. But for document-intensive web applications, such as social networking, blogging and photo-sharing, it's perfect.

The idea is to follow the REST approach:

  • carefully construct a URL for every resource important to your site
  • decide which resources require create, review, update, and delete (CRUD) permissions
  • enable HTTP PUT, GET, POST, and DELETE commands against these URLs

Even if these resources are eventually stored in a relational database, this approach totally shields the relational viewpoint in favour of the document.

You can even write most of the server-side code in XQuery. The advantage of doing this is that it fits perfectly with (X)HTML and REST - you can GET documents, extract the relevant parts using XPath, and insert them into page markup using straightforward inline code. No object orientation in sight!

After all, server-side code does four things:

ActionTechnology
read / update a databaseREST, HTTP
get / set HTTP headersXQuery functions
manage sessionsXQuery functions
construct HTML outputXQuery, HTML

It's very useful if you've got a huge number of URIs (as per REST) - you just have a central application that parses the URI and returns the appropriate mashed-up resources. XQuery is good at this parsing and returning.

One for the future

Unfortunately, the technologies behind REST and XQuery are still very immature and there isn't much support from libraries, documentation, or tools.

And given the immense standing base of relational databases and object-oriented code, and their use in so many different areas, I can't see their support diminishing soon.

That's ok - the point is that new ideas are still bubbling forward for improving developer productivity. SQL and OOP both pre-date the web; they have survived well, but it's always worth taking a step back and asking if there's a better approach.

Harry Potter technology: animated paintings

There's a great scene in the film Harry Potter and the Order of the Pheonix when Hogwart's caretaker, Argus Filch, is taking down an old tudor oil painting. As he twists the painting to remove it, the men in ruffs get angry, shaken from side to side, and eventually fall off the bottom.

It's visually stunning, but also emotionally engaging - it gives the viewer a real connection with the men in the painting. Imagine owning a photo frame that did this!

In fact, it must already be possible to create this effect for real, perhaps using the iPhone (since it has tilt sensors).

Surely picture animation is the next huge area for art - a way to break out of the static image and into lifelike, arresting motion. Why shouldn't the next Lucian Freud create animated paintings?

It's also one of the first digital art forms that isn't a direct copy of an analog one - unlike photography or film cartoons, you simply can't do it using paper. And it seems an even better idea than that other Harry Potter gem, the whereabouts clock.

All we need now is an open standard that describes such animation - I don't think SMIL really cuts the mustard...

From financial services to financial management

I don't think banks really help me manage my money. They might store it securely, give me interest, enable transactions, and offer statements, but that's a short list of services - it's not the whole picture.

For example: what about allowing tagging and categorizing of each statement entry, so I can see how much I spend in the supermarkets or on the gas bill each month?

What about helping me with my tax? Or offering reporting and trending? Or providing financial planning tools? Or customized email / SMS alerts (or even customized financial transfers) when I reach various thresholds?

Drill-down and comparison

I've got online accounts with various different utilities and retailors, but I've forgotten many passwords and don't get around to visiting them very often.

So, imagine if I could click an entry in my statement, and be taken to the relevant website - e.g. click on an entry from the water company, to see my online account there. It just requires my bank to know the URL for common providers (or even store my usernames and passwords).

That way, my bank is truly helping me organize my finances and track my expenditure. It's moving from offering basic banking services to helping me manage my bills.

I could even pick a utility or shop, and view a timeline with all the money I'd spent there. It could link to a shopping comparison site, to help me understand the competition.

Financial Management is more than Financial Services

I don't think they understand this, but banks are a long way from truly enabling people to manage their financials. They're stuck in a decades-long cycle of improving efficiencies, and it's time to open up new capabilities for their customers.