April 13th, 2009

I see at least 4 things wrong with this code

I saw this code over on Ayende’s website. I see at least 4 things wrong with this code, which was found here.

public object DeepCopy (object value)
{
    try {
        return value;
    } catch (Exception ex) {
        throw ex;
    }
}

See if you can find them all.

Tags: ,

Social: kick it on DotNetKicks.com | Shout it | Add to DZone |

This entry was posted on Monday, April 13th, 2009 at 4:38 pm and is filed under News, Personal, Programming. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

One Response to “I see at least 4 things wrong with this code”

  1. Lee Dumond Says:

    1. It doesn’t actually copy anything (except for the reference).

    2. It catches System.Exception, which is generally pointless.

    3. It doesn’t actually handle the exception. If you aren’t going to handle it why catch it?

    4. It resets the call stack.

    Goes to show you how much credibility CodeProject has.