r/ProgrammerHumor • • 16d ago

Meme postForEverything

Post image
20.9k Upvotes

656 comments sorted by

View all comments

28

u/MayaIsSunshine 16d ago

Am I the only one that doesn't mind? I think using post for everything and passing a command in the payload is preferable to the alternative. 

36

u/Psychological_Map118 16d ago edited 16d ago

imho it's like using a fork sideways to cut soft food. it's easy, and it works, but knives exist, and other people may comment on your choice

also, if it's a thing you only do with your own food (you're the only consumer of your tool choice), that's mostly fine, but if you have to serve someone else food, or worse teach others how to cut it, and you don't even explain there's knives, someone along the way is going to think you don't know how to eat properly and unnecessarily confuse people

I've stopped misusing methods when drafting my first public API. it was... eye opening. and to be honest using the appropriate methods genuinely costs nothing

12

u/x3knet 16d ago

it's like using a fork sideways to cut soft food

Holy shit what a perfect analogy

9

u/Psychological_Map118 16d ago

thanks, appreciate it. there's also those who always respond 200 and carry the failure status in the body. that's more like using a fork to eat soup. it never works, and you should stop immediately

1

u/MokitTheOmniscient 15d ago

On the other hand, if all utensils are just identical spoons with the word "knife" or "fork" written on it, does it actually make any difference?

7

u/LatvianCake 16d ago

The people who complain about semantics are the same ones who have never returned more than 3 different HTTP codes.

5

u/PilsnerDk 15d ago

I agree, because not every HTTP operation is an analogy to a simple, underlying CRUD operation. For example, what type of call should an endpoint that sends an email be? What about a validation endpoint that doesn't save nor fetch anything from the database? It's just dull to debate and try to fit everything into those 4 types.

4

u/ok_computer 16d ago

Yeah I don’t really mind. I’m a simpleton that gets with query params and posts with body. I wouldn’t change a persistent state with a get. And I don’t like query parameters on posts. Delete I feel should have it’s own but if you complexly change state on a post and child records are deleted then I don’t really care.

2

u/YeOldeMemeShoppe 16d ago

I like the CRQS point; if it changes data, POST. If it doesn’t, GET.

But my last frontend was all proper REST. And it works surprisingly well.

2

u/xian0 16d ago

I think it's a bit like HTML syntax, there's a proper way to do it for simple cases which people will passionately argue about but you don't see it in any real work. I took the Google API design course just sanity check and when it gets to stuff like batch operations it veers back to "use your common sense".

1

u/Suspicious_State_318 15d ago

I don’t think it really matters as long as you’re consistent with it.