The Danger of The Code Project

I’d say it’s the sheer number of hacks available with minimal discussion or explanation, coupled with the tendency of these kinds of sites to outrank MSDN on google for certain things. This isn’t necessarily a critique of The Code Project site specifically, but rather internet code snippets in general.

I was writing a Windows service today, and I wanted it to have a tray icon to provide access to some options. This isn’t as straightforward as adding a NotifyIcon component, because by default services aren’t allowed to create windows and so forth.

After some googling I came across this.

Now, bitter experience has already taught me never to trust internet code samples. I won’t go into that. But what was interesting was that this article goes so far as to mention:

I am assuming that Microsoft left this out for a reason…

Well, as it turns out, they did. There are at least a few security concerns in this situation, and one should be more educated on the subject than I am to attempt it. At that point I backed up and went with a client/server control model. It was more robust anyway, but it would take longer to write.

I would be interested to know how many authors of production code grabbed and used this code snippet without a second thought. It was the top search result for my terms, so I’m guessing it would be a high number.

The tendency of people to believe everything they read is of course not new.

Tags: , , ,

Leave a Reply