Episodic Genius


occurring occasionally and at irregular intervals


RESTed

I usually write on Friday evenings. This last one, however, I fell fast asleep and slept all night long. I didn’t even think about writing until late on Saturday. I must have working too hard or something. I just needed a good nights rest. I got it and it felt good.On an unrelated topic, I’d been thinking about Roy T. Fielding’s dissertation, “Architectural Styles and the Design of Network-based Software Architectures.” As a person who appreciates a layered and scalable architecture I don’t believe that the principles in his REST architecture can be ignored. I have to admit, though, I had never actually read his dissertation until this week.I’ve been a fan for a few years now. I’ve designed and implemented some small scale systems based on the principles of REST. I’ve become familiar with Restlets in Java and also Jax-RS, which I tend to like working with a little better. I think that even on a small scale, following the principles can make the components easier to develop, test and maintain.I’ve been especially sensitive to the testability in the past few weeks. At my company, I’m working on an application that was designed before I came on and maintains session state exclusively on the server. It can be hard to develop higher level tests for the application because I’m forced to start the server and perform a couple of requests to the server just to coerce it in to the state it needs to be in to run the test. This is cumbersome and it is hard to maintain because the test depends on a lot more that can change (and has changed). I’ve started to get some traction for refactoring the application to store session on the client. They are particular excited about the session information not being lost when their server gets restarted.I noticed a few things in the dissertation that I didn’t know were in there. There is a section in which he makes a distinction between resource mappings that change over time and those that always map to the same value. I’ve made this distinction in the past. It is an important distinction to make when you are thinking about how to use caching but I’ve never been able to explain it as clearly as he does. Later, he says, “An interesting observation is that the most efficient network request is one that doesn’t use the network.” I think he was on to something. I’ve developed my own techniques to improve application performance by paying to these very simple ideas.The last thing I wanted to mention is that he says “requests and responses have the appearance of a remote invocation style, but REST messages are targeted at a conceptual resource rather than an implementation identifier.” I haven’t quite wrapped my head around this yet. I just wanted to throw it out there. Maybe I’ll have more to say on it later.