Forum: Ruby on Rails What is 'Representational State Transfer'?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C7da1c726f89b6b7c37e8a22c0e0382d?d=identicon&s=25 Amita Bhatkhande (amita0204)
on 2009-04-27 21:55
I have read about REST, but never really understood meaning of
'Representational State Transfer'. I tried to read Fielding's
dissertation, but did not understand this term and why has he used it.
What does it mean? Which state? What transfer?

Thanks,
Amita.
280b78a61a968391b7e07e912be102a8?d=identicon&s=25 Robert Walker (robert4723)
on 2009-04-27 22:16
Amita Bhatkhande wrote:
> I have read about REST, but never really understood meaning of
> 'Representational State Transfer'. I tried to read Fielding's
> dissertation, but did not understand this term and why has he used it.
> What does it mean? Which state? What transfer?

I'm not sure anyone knows why Fielding used this term. I suppose he had
to call it something, so that's what he chose.

However, I'll try to explain it as I understand it:

Representational:
The web consists of resources in the form of web pages that are
represented using a Uniform Resource Identifier (URI). REST extends this
definition to refer to other types of resources of an application (i.e.
database tables). Which, can also be represented using a URI.
http://example.com/posts/1 represents the first Post resource in the
posts collection.

State:
This is the current state of the resources.

Transfer (or more precisely State Transfer):
The act of modifying the current state of the resources. Adding a new
one, modifying an existing one, deleting an existing one, etc.

REST defines a convention of using HTTP to both represent and change the
state of resources. That's a close as I can come to defining
"Representational State Transfer."

Hope that helps.
7fe5937b838b580eeaa061c85f700583?d=identicon&s=25 Commander Johnson (Guest)
on 2009-04-27 23:17
(Received via mailing list)
I for one found this post very useful.

On Mon, Apr 27, 2009 at 10:16 PM, Robert Walker <
F53b05cdbdf561cfe141f69b421244f3?d=identicon&s=25 David A. Black (Guest)
on 2009-04-28 00:33
(Received via mailing list)
Hi --

Robert Walker wrote:
>
> Representational:
> The web consists of resources in the form of web pages that are
> represented using a Uniform Resource Identifier (URI). REST extends this
> definition to refer to other types of resources of an application (i.e.
> database tables). Which, can also be represented using a URI.
> http://example.com/posts/1 represents the first Post resource in the
> posts collection.

A resource in the REST sense isn't anything as concrete as a database
table, though. It's more conceptual. As Fielding says: "The resource is
not the storage object. The resource is not a mechanism that the server
uses to handle the storage object."

> State:
> This is the current state of the resources.
>
> Transfer (or more precisely State Transfer):
> The act of modifying the current state of the resources. Adding a new
> one, modifying an existing one, deleting an existing one, etc.
>
> REST defines a convention of using HTTP to both represent and change the
> state of resources. That's a close as I can come to defining
> "Representational State Transfer."

My nutshell take on it is something like this:

A given system gives and receives representations of resources. A
resource is a very high-level construct; a representation is more
specific, and has a content-type and so forth. Resources don't. (Even
more low-level are matters of storage, which may vary and which are not,
themselves, either resources or representations.)

A resource is always in a given state. Resource states are altered via
the exchange of representations. So if I want to correct the spelling of
my name on a site, I submit a representation of my profile with the new
spelling (probably in the form of a Web form). If I want to make sure
it's OK, I request a representation (probably in the form of an HTML
document) to inspect.

I've written a bit more about this on these blog posts:

http://dablog.rubypal.com/2008/3/23/splitting-hair...
http://dablog.rubypal.com/2008/4/24/splitting-hair...

specifically in a Rails context. (Wow, was that more than a year ago?)


David

--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Now out in PDF: The Well-Grounded Rubyist (http://manning.com/black2)
"Ruby 1.9: What You Need To Know" Envycasts with David A. Black
http://www.envycasts.com
280b78a61a968391b7e07e912be102a8?d=identicon&s=25 Robert Walker (robert4723)
on 2009-04-28 06:44
David A. Black wrote:
> Hi --
>
> Robert Walker wrote:
>>
>> Representational:
>> The web consists of resources in the form of web pages that are
>> represented using a Uniform Resource Identifier (URI). REST extends this
>> definition to refer to other types of resources of an application (i.e.
>> database tables). Which, can also be represented using a URI.
>> http://example.com/posts/1 represents the first Post resource in the
>> posts collection.
>
> A resource in the REST sense isn't anything as concrete as a database
> table, though. It's more conceptual. As Fielding says: "The resource is
> not the storage object. The resource is not a mechanism that the server
> uses to handle the storage object."

Absolutely. Thanks David for this elaboration.

> A given system gives and receives representations of resources. A
> resource is a very high-level construct; a representation is more
> specific, and has a content-type and so forth. Resources don't. (Even
> more low-level are matters of storage, which may vary and which are not,
> themselves, either resources or representations.)
>
> A resource is always in a given state. Resource states are altered via
> the exchange of representations. So if I want to correct the spelling of
> my name on a site, I submit a representation of my profile with the new
> spelling (probably in the form of a Web form). If I want to make sure
> it's OK, I request a representation (probably in the form of an HTML
> document) to inspect.

Nice explanation. I look forward to reading your articles when I have a
few spare moments.
Eaf2df1c2be4f7f4a788a919e0c36b1d?d=identicon&s=25 JDM (Guest)
on 2009-04-28 18:47
(Received via mailing list)
David,

Your posts are certainly an interesting aside on the IMproper usage of
the term "resource", but it doesn't (for me) answer the original
question:  "What is Representational State Transfer?"

Like Amita, I struggle with this.  My hope is to someday have a
succinct way of expressing the answer, without being forced to convey
all of the detailed nuamce of Fielding's dissertation (which I don't
really grasp in any great detail).

I kinda like where Robet was going, but I'll suggest a slight
rephrasing:

"Representational State Transfer defines a convention for using HTTP
to both identify and manipulate related information that is
conceptually mapped into an aggrregate construct referred to as a
Resource."

I repeat - I don't really understand all of the detailed nuance.  I'm
struggling to create a simple articulation of the basic idea.

Is my articulation sorta, kinda, in a way, maybe correct?  How can my
articulation be improved?


Jim Maher
6f9833bac86f685067d44b09a138b228?d=identicon&s=25 Aa Wilson (aawilson)
on 2009-04-28 22:04
JDM wrote:

> "Representational State Transfer defines a convention for using HTTP
> to both identify and manipulate related information that is
> conceptually mapped into an aggrregate construct referred to as a
> Resource."
>

> Jim Maher

Quite succinct.  I like it.
280b78a61a968391b7e07e912be102a8?d=identicon&s=25 Robert Walker (robert4723)
on 2009-04-28 23:35
JDM wrote:
> I kinda like where Robet was going, but I'll suggest a slight
> rephrasing:
>
> "Representational State Transfer defines a convention for using HTTP
> to both identify and manipulate related information that is
> conceptually mapped into an aggrregate construct referred to as a
> Resource."

Thanks for the vote of confidence. I certainly don't claim to be an
expert on the subject. There are a lot of people smarter on this stuff
than I, which is why I tried to remain somewhat abstract. I do like your
rewording of my original thought. It certainly seems like a good start.
However, as David pointed out in his excellent blog postings, this
definition may still be omitting one important aspect of REST, which is
the distinction between a "resource" and a "representation" of a
resource. I feel that I have a good mental grasp on this distinction,
even if I'm not so great at applying the concepts to the written word.
Eaf2df1c2be4f7f4a788a919e0c36b1d?d=identicon&s=25 JDM (Guest)
on 2009-04-29 01:31
(Received via mailing list)
I guess I was trying to duck the issue, but I see that does nothiing
to elucidate the use of the word "Representational" in the REST name.

I'll suggest this change (though its getting quite wordy):

"Representational State Transfer defines a convention for using HTTP
to both identify and manipulate related information that is
conceptually mapped into an aggrregate construct referred to as a
Resource, via the transfer between application components of
Representations that contain the current or intended state of that
Resource."

Whadda ya think?


Jim Maher


On Apr 28, 4:35 pm, Robert Walker <rails-mailing-l...@andreas-s.net>
This topic is locked and can not be replied to.