In a RESTful web application design, you typically first identify the resources in your application, the nouns. For example, imagine you're writing a library app., and you're working on adding items to a catalogue. So you've got catalogues and items as your nouns.
You then decide to implement the operations on items, which live in the catalogue. In REST, HTTP verbs map onto the operations you want to perform: POST = create a new resource when you don't know what its identifier should be; PUT = update; DELETE = delete; GET = query resources. So you might end up with:
|HTTP request||Operation performed on resource||Returns|
|GET /catalogue/items?term=potter||Retrieve items containing the term "potter"||Representation of items, with a 200 OK status code|
Request body contains representation of new item
|Add a new item to the catalogue||201 Created status code, with Location header set to URI of new resource, and representation of resource in response body|
|PUT /catalogue/items/<control number>|
Request body contains representation of updated item
|Replace existing representation with an updated one||200 OK status code|
|DELETE /catalogue/items/<control number>||Remove item at the specified location||204 No Content status code|
Fairly typical REST.
Then you realise you want to upload a whole pile of items at once, embedded in a single request for efficiency; but you don't want the client to have to wait while the items are inserted into the catalogue and properly indexed etc.. Maybe it will take 5 minutes or something, and you don't want to leave a web client hanging. Or perhaps you want to upload only a single item, but once items are uploaded they are put into a queue for processing by another system, so there's a wait.
What are your choices? Here are some ideas, partly gleaned from the RESTful Web Services book:
However, what I'm not so keen on is the idea of a job or service being a resource. Why? Well, if I want to create items in my catalog, I don't want to wrap them in a job and post them to /jobs; if I want to query my items, I don't want to have to go to a query service at /services/query or similar.
What these paths hint at to me is that an operation is being represented by that path, rather than a resource: effectively, calling them is like doing RPC: you pass the resources you want to act on as arguments to the procedure you're calling. Often, there's also some implicit resource hidden away behind the job or service. Compare:
It's kind of like the difference between object-oriented design (REST) and procedural design (RPC). While a job might look like a resource, my opinion is that it's really an amorphous wrapper around the real resource you should be representing. Typically, jobs get introduced to cope with asynchronous updates; I'd prefer to see asynchronous operations occurring on proper resources, but exposed using the batch processing approaches outlined above. Otherwise I fear you might lose your resources inside some vague blob of a "job" or "service".
I put myself in the scruffies camp, probably, though I always had a yen for predicate logic and formal grammars. To my mind, some of the AI scruffies weren't scruffy enough, and tried to model human intelligence without any reference to psychological data. I tried to redress the balance a bit, and compared my program's output with psychological data on human inference during story comprehension. You can read all about it here.
At the time I did my Ph.D., I was pretty unfashionable, as I was researching symbolic AI approaches, while everyone around me seemed to be doing neural networks. However, I thought that while sub-symbolic approaches might produce intelligent output, I struggled to see how that would lead to a description of the solution, or anything that might be built on or added to by humans. If you're trying to program a reasoning system, for example, is it enough to train a neural network to create associations, or do you need to write something which can reflect on the process by which it reached its solutions? Neural nets are great for recognition tasks, but I was never convinced they were suitable for reflecting on how they completed the task. I'm sure there are plenty of counter-arguments to my limited opinion, so feel free to enlighten me.
What I've been up to recently, tech first:
I did a presentation on Rails to some students at Coventry University tonight, as part of their e-commerce M.Sc. course. Here are the materials (introductory presentation on Rails and a script for a demo. of Rails functionality).
An excellent summary of the pros and cons of various fruit. Beware the swear.
A poem I come back to all the time. Superficially simple, but with such clear, painstaking and vivid imagery; I love the gentle falling rhythm in the lines towards the end of the poem, how each line pivots around its centre. Shame I can't really appreciate it in its original language (German).
Together with me recall: the sky of Paris, that giant autumn crocus...
We went shopping for hearts at the flower girl's booth:
they were blue and they opened up in the water.
It began to rain in our room,
and our neighbour came in, Monsieur Le Songe, a lean little man.
We played cards, I lost the irises of my eyes;
you lent me your hair, I lost it, he struck us down.
He left by the door, the rain followed him out.
We were dead and were able to breathe.
How do you decide what you enjoy? What does "enjoy" mean, anyway?
Which leads me to the related questions: Why do we engage with art? What do we get out of it?
I am quite obsessed with this as an issue. I spend a huge amount of time and money on music. I love music. I can talk about my favourite bands all day. But my engagement with it is shallow, in terms of how well I can talk about it: I don't understand music in a technical way, even though I think it engages me both intellectually and emotionally. What am I getting out of it?
(I love dancing, by the way. You might not think that. I rarely go to clubs. But I absolutely love dancing. I used to go to loads of club nights at university and just immerse myself in the music, especially the beats and basslines. Now it's restricted to the kitchen while I'm washing up. I don't really like dancing at weddings or parties, mind.)
And recently I've got back into reading science fiction books. I love science fiction, too. Again, though, my engagement is shallow: I know about its history, general themes, I can recognise writers and styles, but I don't theorise deeply about its deeper meanings. I'm happy to just chat about it. (Though I did write a dissertation on JG Ballard and William Burroughs once.)
On the non-art side, I enjoy gardening a lot. I can lose myself when I'm out in the garden, pruning, weeding, sowing, just looking and smelling and hearing the garden around me. I think that is one of my purest enjoyments; I particularly enjoy it because I don't feel I have to intellectualise it. Maybe that's my problem with engaging with art, I think too much about it. Isn't that the point?
I've excluded familial relationships and friendships from this monologue: I don't so much enjoy these, as experience joy (and pain) because of them. Is this the same as enjoyment?
I've also excluded computers. As I work with them all the time, I have a love/hate relationship with them. I can't make a blanket statement that I enjoy programming. Often I don't. Sometimes I find it intensely frustrating and limiting. Other times I find it mind numbing. Then other times I get so engrossed that hours pass without me moving to eat or go to the toilet. It's one of those things.
I suppose what I'm getting at is: I don't feel I have a deep love for any hobby or pastime. Perhaps rather than "love" I should say I don't feel consumed by anything, or driven, or ambitious, or even that passionate. Should I be? Does it matter if I'm not? Is it just the time of year? Maybe I watch people on TV culture shows too much and think I should be able to intelligently discuss my experience of the world, the same way the participants on those programmes do. Perhaps I should just relax.
What do you enjoy, by the way?
(Now I've written all this, I'm not even sure why I did it. Perhaps it's because I've spent the whole day listening to Orchestral Manoeuvres in the Dark, a band I love and have done for 20 odd years. It made me wonder what it is about music that I like so much. And why I place so much importance on a person's music taste as a measure of their personality. I probably shouldn't, but I do.)
My mind is like the autumn moon
Shining clean and clear in the green pool.
No, that is not a good comparison.
Tell me, how shall I explain?