On the soapbox

Published February 08, 2006
Advertisement
As you may or may not know, in addition to being a moderator, I'm also one of the editors for gamedev.net. (Though if you've received a rejection from us in the past year or so, chances are I'm the one who wrote it.) One thing I've noticed, not just in the articles gamedev receives (though it's one of those that prompted this rant) but in articles published on the internet on the whole, is the general lack of error handling or even detection code in article source code. Often this is in the cause of "clarity" or some such other worthy cause.

Today I wish to say: "Well, screw that."

I feel like entire generations of coders are growing up not knowing how to deal with error conditions because they're constantly learning from sources that don't acknowledge that network failures occur or that you occasionally receive bad input from the user. (Or if you're a compiler writer, you constantly receive bad input from the user, but I digress.)

So leave it in. If you're writing exception safe code, say which guarantee that your functions give. Check those return values. Go ahead and call GetLastError(). Throw those exceptions and make those assertions.

Despite our best efforts to the contrary, people still are learning programming by imitation. We can't stop that, but we can at least give them good code to imitate.
Previous Entry Week/Session 3
Next Entry Week/Session 4
0 likes 6 comments

Comments

jollyjeffers
Agreed, but unless it's the topic of the article I think it should be left out of the main body of the article. Put it in the accompanying code download/listing...

When you have a few relevant lines of code included interspersed with explanation I'd prefer to keep it short and not have too much error handling code with it [smile]

Jack
February 08, 2006 04:24 PM
MustEatYemen
How about, two code samples. Both the code trimmed for "clarity" and a complete code solution w/ proper error handling etc.

Then again I suspect that some of the lack of proper error handling stems from the fact that people don't have time to create a finally tuned code base just to demonstrate what they see as simple concepts.

I know I'd hated writing a error handling direct3d initiliation routine. Haven't touched it for years :D
February 08, 2006 07:35 PM
ApochPiQ
IMHO, articles should have all error handling inline, and explain the error handling, too. Handling bad mojo is a very important part of building software, and nobody should learn a new technique, tool, technology, or API without learning how to handle its bad mojo.

My vote is to just start rejecting articles that don't do this... but that's just me [wink]
February 08, 2006 11:04 PM
jollyjeffers
Quote:IMHO, articles should have all error handling inline, and explain the error handling, too. Handling bad mojo is a very important part of building software, and nobody should learn a new technique, tool, technology, or API without learning how to handle its bad mojo.
I agree, but what you're saying seems to be less relevant the more advanced the article is.

Beginner/intermediary tutorials/articles in a given field should definitely cover it, but an advanced article should leave it from the body of the text and have it as a code download...

I'm just thinking in the context of what I read - when reading some of the more advanced graphics algorithms papers I want to get to the "meat" and not have to go through 3 pages of "this is how you use a keyboard" introductory material [lol]

Jack
February 09, 2006 02:15 AM
superpig
I agree that error handling code should be in the attached source file, and I'm generally against huge chunks of article-inline code anyway. I hate the NeHe style.
February 09, 2006 06:31 AM
SiCrane
I was thinking inline code would be the clear, concise version, but the attached source file would have the error handling code.
February 09, 2006 07:58 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

New bug to me

1682 views

Week/Class 9

1519 views

Week/Class 8

1560 views

Week/Class 7

1607 views

The promised files

1836 views

Week/Class 6

1302 views

Week/Session 5

1358 views

Week/Session 4

1297 views

On the soapbox

1399 views

Week/Session 3

1275 views
Advertisement