Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    195
  • comments
    198
  • views
    104374

On the soapbox

Sign in to follow this  
SiCrane

356 views

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.
Sign in to follow this  


6 Comments


Recommended Comments

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

Share this comment


Link to comment
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

Share this comment


Link to comment
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]

Share this comment


Link to comment
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

Share this comment


Link to comment
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.

Share this comment


Link to comment
I was thinking inline code would be the clear, concise version, but the attached source file would have the error handling code.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!