Welcome to Marlon's place!


Message of the day


"There is a brave man waiting, who'll take me back to where I come from"


(The Black Heart Rebellion)

A small rant about code snippets

posted: August 28, 2009

Normally, I'm not the person to rant about subjects, nor am I one to look a gift horse in the mouth. However, there's something that's been bothering me for a while...

For a software developer, it's almost impossible to have an encyclopedic knowledge of the entire language you're using, especially when you need to balance your time between several languages.

As a result, one of the traits that makes a good software developer is the ability to quickly pick up the basics of a certain language (including best practices), and being able to find your way around whatever documentation you can find in order to fill in the blanks you need.

That's where the internet kicks in: even though we'd all like to be the first to do something new and innovative, chances are someone on this very planet has already solved your problem. That's why websites with code snippets are so popular - why reinvent the wheel when you can profit from the knowledge available on the internet?

Now don't get me wrong - I absolutely love websites with knowledge bases, code snippets and all sorts of faqs. I even try to post some knowledge of my own from time to time, hoping that someone, somewhere will find it useful.

But - and this is what's been bothering me for quite some time now - I really dislike the way some of these articles are presented on the internet. There are a lot of articles out there showing you how to use "procedure x" in Delphi, "method y" in Java or "function z" in C++ or equivalents, omitting the most basic information: where to FIND that procedure, method or function.

Why on earth would you omit such basic, yet much needed information? What good does it do me to know that I can use the function "void sleep(unsigned seconds)" to pause my program for a while, when I don't know where to find said function? Honestly, it would have been better to hint towards the header where the function is defined, and have me find out on my own, that way I would have had to read through parts of the header, possibly learning a few additional things I did not yet know.

It's happened to me several times already: I Google for a certain function, or something I'd want to do, only to find a lot of samples, none of which I can use because I cannot seem to find out what header/unit these functions are in. Not only is this very annoying, if you're learning a new language it's also very annoying. It's almost as if people don't want you to learn the language, therefor making it harder for you to gain knowledge.

Basically, what I'm saying is this: if you've written an article about a snippet of code you'd like to share with the world - include the includes!

By the way - "void sleep(unsigned seconds)" can be found in header dos.h (for DOS/Unix) or unistd.h (Unix), should any of you C-programmers ever need it.

Previous articles

Recent C++ stuff

Recent Delphi stuff

Recent Java stuff