blog.jj5.net (2003 to 2005)

throw new NotImplementedException

Wed Jun 23 18:48:00 UTC+1000 2004

Categories:

There are two types of NotImplementedExceptions.

One is the WillNeverBeImplementedByDesignException, and the other is the ImBusyAndIllImplmentThisSoonButItsNotAsImportantAsSomethingElseRightNowException.

The former are fine, just use 'throw new NotImplementedException()'.

The problem with the latter is that you might forget to implement it! Even if you don't 'forget', you might have trouble 'finding' it.

So, I've created a DebugHelper class, which contains a static void ThrowNotImplementedException() member. Then, when I haven't got time to implement a method I can call that method instead of throwing the exception directly. I can #if out the definition for a release build, and I can even just comment it out for a debug build to find what is outstanding.

Further, I can add a static void ThrowNotImplementedException() to a 'class' to get even another level of indirection if I think that will be useful.

I'm glad someone else thought of it! ;)

John.


Copyright © 2003-2005 John Elliot