DEV Community

Discussion on: Explain RESTful just like I'm five

Collapse
 
tsundara profile image
Thyag Sundararmoorthy • Edited

Look at the real world.

The real world has things (such as books and car)
Something can be done to these things (create, edit, delete)

The things are called "resources". Create, modify, and delete are called behaviors.

Through the 70's until early 2000s, we were building software functions in which things and behaviors were "coupled".For example, if you had to do something to a book named "da_vinci_code" you would do this:

  • readBook "da_vinci_code"
  • createBook "da_vinci_code" "some data"
  • modifyBook "da_vinci_code" "some data"
  • deleteBook "da_vinci_code"

The funtion name "readBook" can very well be named "scanBook". The function name "createBook" could have been named "instantiateBook".
This means, the developer needs to ADVERTISE/PUBLISH the name of each and every function. As a result, the documentation became huge and expensive to maintain.

REST is a way to neatly separate behaviours and things. Now you would actually do this :

As you can see, there are only 4 popular behaviors (verbs) - GET, POST, PUT, DELETE
But the number of things (resources or nouns) can be infinite.
Note that things can be collections (book) and the thing itself ("da_vinci_code")

Thinking in terms of GET, POST, PUT, DELETE is simple and practical.

So REST is basically a way to design the interaction of things on the internet.