HAVE YOUR CAKE AND EAT IT TOO (Representational State Transfer)
- Winnie Au
- Aug 5, 2015
- 2 min read
Today, along with the task of researching GET requests and POST requests, we familiarized ourselves with the concept of REST, or Representational State Transfer. That's a mouthful, isn't it? Ironically, the purpose of REST is to (more or less) make things a whole lot easier in many ways. How? REST is "a programming architectural ideology intended to increase the efficiency of computing systems [which] embodies the idea that the best way to share large amounts of data between multiple parties is to make that data available on-demand by sharing references to that data rather than a complete copy of the data itself."
?xml version="1.0" encoding="UTF-8" standalone="no"?https://simple.wikipedia.org/wiki/Representational_state_transfer
This can be a little difficult to picture for someone who hasn't spent some time actively trying to understand it, so I will provide an analogy (based on food of course, because who doesn't like food) which will hopefully clarify things a bit, and maybe also make you want to eat.
So imagine you're in a busy restaurant, like a popular diner. Diners tend to serve many different options. Now imagine if every time any person in the diner wanted something to eat, the chef/cook had to prepare every option available just so the person could see every item and then choose only the specific thing(s) he/she wanted. This would be incredibly inefficient and the whole procedure would be a headache for everyone involved. This is where menus come in handy. The menu is a representation of everything that is available at the diner. Instead of the cook/chef having to make and bring out every item available for consumption at the diner, the customer can just be given a menu which gives each item on the list a name(an identifier of sorts), and provides a method for the customer to refer to any particular item or items and order it.
This is precisely what REST allows. Instead of having all the items/data available to begin with and then choosing what is wanted, REST provides references that represent each item/piece of data which can be requested individually instead of simultaneously getting a bunch of other things that are uncessary.
In a way, with REST we can have our cake and eat it too (not to mention make it bigger, since REST is more scalable than the SOAP alternative which I will get back to you all about in a different post).
Comments