Thursday, May 7, 2009

Is Resource view (REST) as powerful as Object view?

We are comfortable with object view of the world. Everything is a class and each class has data members and method members and has relationships to other classes. In plain English we have nouns and verbs. If you are user of a object API, you get the right noun instance and call the verb on it - get the duck instance and say "fly". We can model bank domain to rocket domain using this.
Modeling this as a service as in SOA or method call as in RPC is also straightforward. Calling a method on a remote object is possible (CORBA). And that in turn is equivalent to a method call which has object identity as an argument.
Is Resource view equally powerful? I thought a service "SendEmail" might be tough to be seen as a Resource that has a universal interface (HTTP method). http://www.prescod.net/rest/restmail/ shows that this is possible. Does it look contrived?
Well, we could analyze this with two approaches. By making the whole world look like resources we are converting a set of "nouns and verbs" to fixed few verbs and lots of nouns. I as a human can do many things - run, sleep, think etc. How do i reduce it to nouns? One way is state model approach - i see things as states and each state is addressable by URI. So i have a running man, sleeping man etc. Is a state a resource? Not really.
Another way to look is that we are only interested in representation and transfer of representations between client and server. So you get representation of a resource - which is a man. And you update the resource's representation on client, say you change it from running to sleeping and then you call update onto the resource again. It is like you take a toy look at it and turn the switch on and put it back - the toy starts playing. So any object model can have an equivalent resource model where object are resources, data members are part of representation of object and method calls are triggered on server side by client modifying the representation of object and updating the server. This has an integral part, serialization of object into an representation that can be shipped to far away place and a change could be applied with a returning representation.
On a broader view REST looks like shopping experience. You go to a shopping mall and all shops are resources. You hop from one to another - your state transfers, resource stays where they are and you only get a representation of resource (godown is the actual resource).
It also looks as if REST is remote object protocol - except that methods are not called directly. They however could be effected by state change. How does document style services differ - well, they look more closer to REST than RPC style services. The equivalence is when there are seven kind of services - Get, Post, Head, Put, Delete, Trace and Option.
This again takes me to LISP and turing machine. Anything can be modeled by a simple list or a set of read/write/mark instructions. My faith in higher level ideas like REST is strengthened.

REST is primarily for remote communication. One will not implement their business logic entirey using just resources - it will be object model. REST representations are photographs of these object model - one object at a time.

Monday, May 4, 2009

FREE stack

Flex, REST and Enterprise backEnd

EE could be JEE or Jersey based REST provider. Back-End programming language is Java.

What one should be aware of:

1. Flex doesn't support PUT, DELETE. So if u try hooking xmldb as backend and Flex front-end it will not be out of box.
2. Flex doesn't give u status code back in HTTP response
3. Your major concerns would be how to integrate new app built on this stack with existing infrastructure - especially identity management.

What are some of the pluses that stand out

1. With flex you no longer worry about lower level UI aspects. It is far more faster to develop UI with flex. And it is building bridges with other technologies for backend.
2. With REST you are ready for a developer platform right from the begining.
3. With REST you are web ready. You can take on scale, performance, mashup etc easily.
4. With Java you have a proven platform for doing enterprise application backend.

Sunday, April 19, 2009

Sudoku and Architecture creation

Here is how i solve Sudoku puzzles. I look at the whole problem and try to see from my memory if i have ever seen a pattern like this or even a sub-pattern. If i find one then i try to see if whole or part of or learning from the old solution could be used. In either case i proceed as below. Let me call it pattern approach.

The simplest of sudokus have a weak part of the problem. If you get that part and solve it, suddenly the whole sudoku solution comes up on its own like a thread that has been pulled from a woven cloth. Sometimes it is multiple threads, so when u take out one thread, you have to find the start of another thread and so on. Same might be true when u are solving a huge set of simultaneous equations with pen and paper. You look for equation with least variables or some peculiar form that has clue in it. Looks like a detective approach. Let me call it weakest part of problem approach.

In some of the harder sudokus author removes all the starting points. One can however find a starting point that needs assumptions of a small part of initial solution. One starts, tries it and backtracks on findind deadend. Then starts again with a different assumptions. Let me call it trial and backtrack.

Given the problem specification (i.e. all requirement and context analysis done), an architect tries a similar approach:

1. Pattern approach
2. Weakest part of problem approach
3. Trial and backtrack approach

Sunday, March 8, 2009

Is this online site alive

I have tried lots of social networking sites. But it was only today that i tried plaxo. Here is the first experience on this site. The first wow on a social networking site is finding people you know who are there. Connecting them brings the site alive. What differentiates an online site from a remote data store and remote application delivery site is that it connects with other's data.
There was one more thing that brought more life to plaxo. It collected my internet footprint - it searched blogs and got entries authored by me. Ofcourse a different UI adds to all this.