BrianPeek.com

A Compendium of Random Uselessness
in Search
  • April Fools' Day Application

    My latest article is up on MSDN's Coding4Fun.  Take a look and download a fun application to annoy your friends and co-workers on April Fools' Day.

    As always, questions and comments welcome.  If it's a question or comment that could benefit the masses, please create a new post over on the forum and I will reply there.

    Posted Mar 29 2007, 09:40 PM by Brian Peek with no comments
    Filed under: ,

  • Exception Handlers

    Warning.  Rant coming...

    I was working on a project last week that included code that looked sort of like this:

    public bool SomeMethod()
    {
        try
        {
            // do some lengthy, involved, *critical* process that, 
            // if it fails, will cause the rest of the application to fail *forever*
            // as it leaves a required, persisted resource in a corrupted state
        }
        catch
        {
            return false;
        }
    }
    
    public void SomeOtherMethod()
    {
        SomeMethod();
    }
    Of course, when I was debugging an issue in this application, SomeMethod was failing, yet I had no idea because the author of the code decided to not only throw away the exception that was being thrown, but not bother to check the return value of SomeMethod after it was called.

    So here comes the rant.

    Stop it!  Stop doing this!  Stop catching exceptions and either doing nothing with them, or throwing them away!  It's an exception handler!  If you're not going to handle the exception, don't catch it!

    I see code that does this way too much,  My other favorite is:

    public void SomeMethod()
    {
        try
        {
            // big code
        }
        catch
        {
        }
    }

    An empty exception handler.  Sure, let's run 500 lines of code in a try block and then, if an error occurs, let's not tell anyone.  I bet the people that write these had parents that yelled at them all the time.  In their adult life, they fear the wrath of an authority figure if an error were to occur, so they just throw away the error.

    So what's my point in all this?  If I can just get one person to not write a useless try/catch block, I'll be happy.  Look at your code.  Look at your try/catch blocks.  If you're not doing something important with the exception you've caught in your catch block, or you're throwing away the information altogether, please fix it.  Thanks.

    
    							
    Posted Mar 25 2007, 02:29 PM by Brian Peek with 2 comment(s)
    Filed under:

  • Wiimote and .NET

    Update 3/17/07: A new version of the code and assembly is linked from the article below which fixes a bug with the calibration data.

    My latest article has been posted on MSDN's Coding4Fun.  This time I have created a fully managed library to use a Nintendo Wiimote (and all current extensions) in C# or VB.NET.  You will find a description of what was done, source code for the fully managed library, a test application, and compiled libraries for you to start using immediately.

    As always, if you have questions, problems, feature requests, etc. please contact me and let me know.  If it's a question or comment that could benefit the masses, please create a new post over on the forum and I will reply there.

    Head on over and check it out!

    Posted Mar 14 2007, 04:23 AM by Brian Peek with 43 comment(s)
    Filed under: , , ,

  • Code Camp Lego NXT Source Code

    Well, if you attended my session, you know that something broke with MSRS and connecting to the NXT hardware.  Just so I can prove I'm not a total idiot, I'm sitting outside the session room right now and, of course, everything is working happily.  I downloaded MSRS, did a "Repair" installation, and everything magically came back to life.  <sigh>  Oh well.

    Anyway, I hope everyone was able to get something out of the session even if you didn't see the 'bot move.

    As promised, I have posted the source code (C#, VPL) and the PowerPoint presentation.  You can get the materials here.  If you have any comments, questions, or anything else to say, please don't hesitate to contact me or create a post in the forum for discussion.

    Enjoy, and thanks for attending!
     

    Posted Mar 03 2007, 06:01 PM by Brian Peek with 4 comment(s)
    Filed under: , ,

Copyright (C) 2008 Brian Peek
Powered by Community Server (Commercial Edition), by Telligent Systems