r/learnprogramming • • Apr 05 '22

Name one programming/comp sci concept you never understood and if you understand it, try to explain it to them

Name a programming concept such as virtual functions, pointers, certain algorithms, etc that you always had a hard time understanding and why.

Someone else who reads yours and does understand it, try to explain it to them to help them learn

1.6k Upvotes

738 comments sorted by

View all comments

6

u/Historical_Wash_1114 Apr 05 '22

I'm getting decent at programming and I have no idea what anyone is talking about with RESTFull APIs.

2

u/lionhart280 Apr 06 '22

Usually used for handling data over HTTP(S), usually websites but anything can use it.

RESTful primarily just means it adheres to the HTTP spec for requests, which is just a header on the request specifying its "type", the main ones are "GET", "PUT", "POST", "DELETE"

There's more but those are the main ones people use.

There's supposed to be specific rules that any URL that accepts a POST should also return the same thing back from a GET on the same endpoint.

IE if I POST <data> to mywebsite.com/some-endpoint/11a23f1, then I call a GET on the same endpoint I should get the same <data> back

A lot of people don't adhere to that... there aren't exactly internet police going around demanding you adhere to the rules, but its good practice.

At its core though is the expectation that your endpoints are idempotent.

If I call "GET" on <endpoint> 10 times in a row (without anyone else doing anything to modify the data at the same time), I should get the same value back.

And if I repeatedly POST to the same endpoint over and over, it shouldn't change anything after the first.

Aside from that its just a way of defining a bunch of URLs people can utilize to interact with your application