April 22, 2004

Objects and Services - Nouns and Verbs

Bill de hÓra talks about the use of Objects and Services in distributed computing. He comes down clearly in favor of services, and against objects:

You see, when it comes to distributed computing, I think all object oriention does is obscure matters. We end up talking about transactions, parameters, references, interfaces, when we should be talking about messages, state, names, protocols. And if that doesn't fit with object thinking, so much the worse for it - distribution and decentralization is becoming the norm.

I was confused by what he says; there was something that I wasn’t getting. Clearly, it was an impedance mismatch caused by different worldviews – mine is inextricably linked to the product I’ve been working on, which nobody else knows about yet.

You see, the world is made of objects and services: nouns and verbs. Being and doing. There’s no getting around it. If you want to write programs that do something in the real world, you have to somehow model this, i.e. represent in your program the concepts that you want to manipulate. The only time that you can ignore objects is when you only care about a single one. For example, a stock ticker doesn’t need to explicitly deal with objects because it only cares about a single stock. Or you can consider the whole stock market to be a single object and support a service (verb) that says for example, “Get me the value of PMTC”.

But in complex systems, it simplifies things tremendously if you can model the world as many objects. This is because not all verbs apply to all objects – you can deposit money to your bank account but not to the stock market. Coincidentally, modeling the world as many objects (nouns), each with its own set of applicable services (verbs) corresponds to the way the world really is – no wonder it makes things easy!

Some of you may be wondering: what about adjectives? The real world has adjectives too! Adjectives are known in computer jargon as state. Adjectives describe objects – objects have state. For example: “The brown-eyed boy” or “The boy has brown eyes”. In a monolithic system is possible to directly access (look at) the state of an object. In a distributed system all you can do is ask for it: “Hey boy! What color are your eyes?”. In other words, it is possible to replace adjectives with verbs. Instead of saying, “The brown-eyed boy” you can say, “The boy whose eyes are brown”. In an object-oriented system that doesn’t allow direct access of state, “to be” is a verb, just link in English. (Not true in all languages.)

Getting back to distributed programming, there are two common paradigms for distributed systems: Web Services and REST. (The terminology is somewhat inappropriate; Web Services is a protocol and REST is an architecture, but so be it.) The REST model is what you are all familiar with as the World Wide Web. In this paradigm, you can conceptualize the system as a set of documents, identified by URL. You can GET the document i.e. view it in your browser. (When you click on a link you are doing GET.) And you can POST to the document e.g. when you fill out a form and press “send”.

It is not often described this way, but the REST architecture is object-oriented. The object is identified by its URL, it has a state (the document that you get with GET), and it supports a verbs through POST that are specified per object. (Yes, I know that technically it supports only one verb, POST, but in effect programmers use some of the data that are sent as verbs, others as nouns. I think that good programmers formalize this to themselves and know clearly which are which. In natural languages the same thing happens: In English you can shower, but usually you take a shower. In Hebrew, you don’t say, “I am skiing” you say, “I am doing ski”. Perhaps it would be clearer if we used IS and DO instead of GET and POST.)

Since Web Services is a protocol, technically you can use it to implement a REST architecture, but usually what is meant by this term is that instead of using many URLs in your system to represent many documents (objects), you instead use a small number of URLs to represent verbs of a “service”. In other words, you have to think of a URL as a single huge object – the service – a document so complex that you never what to GET it.

This has been a very long introduction (I didn’t plan it this way) to my attempt at resolving the my impedance mismatch with Bill. He says:

You see, when it comes to distributed computing, I think all object oriention does is obscure matters. We end up talking about transactions, parameters, references, interfaces, when we should be talking about messages, state, names, protocols. And if that doesn't fit with object thinking, so much the worse for it - distribution and decentralization is becoming the norm.

In REST we talk about messages (GET, POST), state (the document), names (the URL) and protocols (HTTP). So what’s his problem? I think he must be talking about session – and that’s another whole kettle of fish.

A session is like a conversation. Computers, like people, have trouble carrying out more than one conversion at time. However, unlike people, they can be programmed to do so. When you use Google, you don’t have a conversation. You ask one question, and get one answer. Your next question has nothing to do with your previous question (except perhaps in your own mind, but Google doesn’t have to know about that). On the other hand, when you make a purchase from Amazon, you do have a conversation. First you say, “I want to purchase the items in my shopping cart.” Then you say, “This is how I want them sent.” And so on, until finally Amazon gives you the receipt. While Amazon is doing this with you, it is having similar conversations with thousands of other people. It could be a disaster if your session gets mixed up with somebody else’s session (things like this have happened). When you get into multiparty conversations, things can get incredibly complex. I think that what Bill is saying is that instead of trying to keep track of sessions, to send all relevant information with each action, so that all interactions can be like your use of Google.

(Of course, my product solves this problem too!)

Bill: Is that right? (I’m sure it’s not, this is my first try…).

BTW, Bill, your blog has a bug which I assume only appears in my browser (IE 5.00.3700.1000) otherwise you would have fixed it. When I click on a link I loose the right margin, and as a consequence the words jump around. I have the same bug in my blog. I see that you’re also using Moveable Type, so the problem might be with the way they expand one of their tags. If you fix it, can you let me know what the problem is? If I find the fix, I’ll let you know - thanks.

Posted by David Boxenhorn at April 22, 2004 12:47 PM
Comments & Trackbacks

In Mozilla or IE6, you have a different problem: Your blog is wider than the browser window. No matter how wide the browser window is, the blog is wider than that.

I think your CSS layout adds up to more than 100% width or something.

In fact, this is probably the cause of your problems in IE5.

Posted by: Pixy Misa at April 22, 2004 05:14 PM Permalink

There's some weirdness going on with the comments template too, but I'm not sure exactly what it is.

Posted by: Pixy Misa at April 22, 2004 05:16 PM Permalink

I had some conflicting relative/absolute information - I think that might have been the Mozilla/IE6 problem - which I took out. Can you test it for me? Thanks.

I'm still have my problem, though. When I click the permalink, the width of the content area expands. It looks like it is not taking its position into account. When I resize the window it fixes itself.

Posted by: David Boxenhorn at April 22, 2004 07:38 PM Permalink

× Network: