Wednesday, November 16, 2005 1:17 AM
by
brian
Not a NotImplementationException for not implemented members?
Overriding an abstract member or implementing the members of an interface using Visual Studio’s code completion inserts the following into the members body:
throw new Exception("The method or operation is not implemented.");
I would expect it to insert:
throw new NotImplementedException("The method or operation is not implemented.");
It is not good practice to catch exceptions of type System.Exception. Why does the IDE generate this code? Where would it be caught if we are to follow the design guidelines?
I generally implement application wide exception handling. If I catch a NotImplementedException while still in development, I display a messagebox. If it is caught in my unit tests, I log it to be sure I get the implementation completed.
Throwing a general exception for a very specific situation like this is counter intuitive. Maybe I am applying this to much to my particular usage patterns, and sure, I could change the exceptions thrown. It just makes the most sense to me to throw the NotImplementedException as the default for members that are not implemented.