I read an intriguing blog post yesterday. It's on old one dating back to 2008, titled

"It's your fault"

submited by
Style Pass
2022-01-15 12:00:05

I read an intriguing blog post yesterday. It's on old one dating back to 2008, titled "Even if a function doesn’t do anything, you still have to call it if the documentation says so, because it might do something tomorrow". That's quite a mouthful, but the article itself is rather short, I can summarise it one paragraph for you.

There used to be a function in Windows Kernel that didn't do anything. Yet, the docs told programmers that this function had to be called after calling another one: if you called GetEnvironmentStrings, you also needed to call FreeEnvironmentStrings. However, many programmers didn't bother to do so because it was pointless: FreeEnvironmentStrings didn't do anything, it was literally an empty function. A couple of years later, that function actually got an implementation, and many applications started to break because their programmers never bothered to call it in the first place.

If the documentation says that you have to call a function, then you have to call it. It may be that the function doesn’t do anything, but that doesn’t prevent it from doing something in the future.

Leave a Comment