Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 4720 RESTfulness CS 4720 – Web & Mobile Systems.

Similar presentations


Presentation on theme: "CS 4720 RESTfulness CS 4720 – Web & Mobile Systems."— Presentation transcript:

1 CS 4720 RESTfulness CS 4720 – Web & Mobile Systems

2 CS 4720 And verily the Intarwebz were created The evolution of the web –Server / Client –Simple pages –Web applications 2

3 CS 4720 And verily the Intarwebz were created 3

4 CS 4720 And verily the Intarwebz were created 4

5 CS 4720 And verily the Intarwebz were created 5

6 CS 4720 The Statefulness… or lack there of… How does state play into SIS? Why? How? 6

7 CS 4720 Nouns speak louder than… verbs… Look at the links in SIS What are they? Verbs. This is the evolution of the web –We have tried to force the web into the same mold as stand-alone programs –This is not good! –We need to take advantage of the asynchronous nature of web communication! 7

8 CS 4720 REST Definition: REST –Representation State Transfer –a software architectural style for distributed hypermedia systems, such as the web –(but not necessarily the web) 8

9 CS 4720 Principles of REST 1. Statelessness In the simplest terms, this principle forbids for any state information to be stored on the server This does not forbid state to be stored client- side Every message though must contain all information needed for understanding 9

10 CS 4720 Principles of REST 2. Idempotency The output of identical requests is itself identical In other words, if you go to the same page twice, you get the same page (barring changes in the content model) Allows for caching, which improves user- perceived responsiveness 10

11 CS 4720 Principles of REST 3. Addressable Resources Everything has its place and every place has a thing Everything is a resource See amazon.com for a good example URLs reflect the resource 11

12 CS 4720 Principles of REST 4. Well-defined operations In the context of the Web and HTTP, were talking: –POST –GET –PUT –DELETE This reflects possible actions 12

13 CS 4720 Principles of REST 5. Formatted/Structured Data The resources you get should be encoded in a uniform way (like HTML, XML, etc.) 13

14 CS 4720 Sounds good… but… Sure sounds hard to pull off good web apps with these constraints… Lets think about a shopping application Whats the usual way? 14

15 CS 4720 RESTful Shopping What are the actions that you want to take in a shopping application? 15

16 CS 4720 RESTful Shopping In real life, who holds the shopping cart? You, or your personal shopping buddy provided by the store? If its you (and I hope it is) where do you store cart information? –In a frame? (UGH… I just threw up a little in my mouth) –In a cookie? (not what its meant for!) –HTML5 SessionStorage object … eventually 16

17 CS 4720 RESTful Shopping Well, just for argument, well give you your shopping buddy (well call him Carl) In this instance, the shopper will be asking the store to set aside items for them The difference here is basically philosophical, but bear with me If we treat the cart as part of the STORE and not owned by the CLIENT, then RESTfulness can still be maintained 17

18 CS 4720 RESTful Shopping 18 SenderMessage ClientShow me your products. ServerHeres a list of products. ClientOkay, Id like to buy 2 of http://shop.com/product/X, place it in my basket, my username is XtremeShopper and password is bubbahttp://shop.com/product/X ServerDone. Ive put it in your basket at http://shop.com/users/XtremeShopper/basket ClientActually, I dont need 1 of those. Please remove one of X from my basket, my username is XtremeShopper and password is bubba ServerDone. Ive removed it from your basket at http://shop.com/users/XtremeShopper/basket ClientGreat. Ring it up - username is XtremeShopper password is bubba ServerShould I charge that to your account?

19 CS 4720 RESTful Shopping Uh… wasnt that a session? Not quite – a session disappears when the user does –Theoretically, this would be around until the user removes everything or checks out It is addressable, its formatted, its idempotent, and it uses defined operations The differences are very subtle, but they are there 19

20 CS 4720 Sounds good… but… REST means that the server is stateless and cannot store any data about the clients current state/session This example was a bit extreme Like most things, moderation is the key to getting the right balance between server and client resource utilization 20

21 CS 4720 Your turn Lets go find some RESTful and non-RESTful apps. Why are they behaving that way? Why do you think they were designed this way? 21

22 CS 4720 22 Review REST REST: Representational State Transfer It is a software architecture style / philosophy, not a protocol / system / etc. Main Principles: Stateless client-server – No state info is stored server- side Identification of resources - Individual resources are identified in requests, for example using URIs Manipulation of resources through a simplified set of operations – In HTTP, POST, GET, PUT, and DELETE The use of structured data – Such as HTML or XML

23 CS 4720 REST Examples What web systems are RESTful? Others? –CS4720 homepage? Yes. –cnn.com? Potentially. –Collab? The architecture potentially, but not the individual modules. –SIS? Is there a rule it doesnt break? Remember the fundamental concept: nouns (resources), not verbs (actions) to interact 23


Download ppt "CS 4720 RESTfulness CS 4720 – Web & Mobile Systems."

Similar presentations


Ads by Google