The Vegan Militia

... because we are all made out of meat!

Status 200 and All Is Well

2023/11/23

So I just ran into a piece of code which looked something like this

request = http.request(someurl)
if (request.status == 200)
{
  mystuff = request.body.foo
}

I showed this to my wife, who knows almost nothing about code. She said “what if it gets a status other than 200?” Despite the fact that her one and only coding class was in high school and she barely remembers it, she has managed to do better than the veteran who wrote that code! I responded, “Well, at least they are checking for the status rather than blindly proceeding!” I should not have said that. Fifteen minutes later, in the same file, I ran into code which was like this:

request = http.request(someurl)
mystuff = request.body.foo

Larry Niven once said “That’s the thing about people who think they hate computers … What they really hate is lousy programmers.”

Tags: programming error